Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[C++]Slow computer perfomance cause physics to work different

I have a pretty usual piece of code performing a free fall acceleration.

 FallingVelocity += FreeFallAcceleration;
 MovementSpeed.Z -= FallingVelocity;
 MovementDistance = MovementSpeed * DeltaTime;

DeltaTime comes from a Tick loop so it's based on frame change time. I guess this code should work the same way on any computer because for one second of calculation any PC should get MovementSpeed.Z = -1 * FreeFallAcceleration*FrameRate. Since FrameRate = 1/DeltaTime, the results should be the same, but... Same character jumps right on the middle of platform on PC#1 but a little overshoots and thus falls off platform on PC#2. What am I doing wrong?

Product Version: UE 4.9
more ▼

asked Oct 15 '15 at 03:16 PM in C++ Programming

avatar image

74 12 17 24

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Depending on how much it overshoots. If not too much - It is normal. On slower computer you'll have less frames per second, so your movement change curve will be less accurately interpolated, so more error will be accumulated during physics calculation. It is a limitation of physics modelling and not too much you can do here. That is one reason why games are usually targeting fixed fps.

Depending on what you mean by overshoot - there can be options how you can fix this.

more ▼

answered Oct 15 '15 at 03:47 PM

avatar image

544 39 50 69

avatar image Unteroid Oct 16 '15 at 02:43 PM

Well, not that much, but it still appears to be annoying. Thanks for explanation though. That's hard to explain how much, but it's like 100 units. What's displayed on pictures is an object (pizza slice like wedge) landing on a jumping platform (stairs like wedge). Difference is enough to miss landing with identical speed and jump height. alt text

adsasdasdad.jpg (186.9 kB)
avatar image Yata Oct 16 '15 at 03:17 PM

You should implement jumping Physics yourself is think. That what i would do. Precompute jumping curve on jump start and than move object along it. And use physics only for collision handling. If any collision occurs - get a hit point and hit vector from it and recompute bouncing curve and move along it, until next collision.

Nice graphics =D

avatar image Unteroid Oct 16 '15 at 04:09 PM

Calculating a curve by hand is a really good idea, thanks, Yata.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question