BraveOtter
BraveOtter

Reputation: 114

How to simulate gravity towards an object, not down

Im trying to simulate gravity to a planet in unreal engine but I don't just want to make an object stick to the surface of the planet, I want to simulate gravity using the equation F = ((m1 · m2) / d ^ 2) · G (Source). And in this way I want to be able to simulate orbits of other objects around. However, I do not know how to do so that the force that results in this equation is applied consistently and homogeneously.

The problem with using the "Tick" event is that it is executed in each frame, so the force applied depends on the number of fps and is not constant, so I cannot keep an object in orbit (it ends up moving away or crashing against the planet).

How can I get this force applied consistently without depending on the number of fps?

Upvotes: 0

Views: 1007

Answers (1)

Rotem
Rotem

Reputation: 21927

The Tick event provides you with a parameter DeltaTime which represents the time in seconds that has passed since the previous tick. On each tick, you should advance your simulation by this amount of time.

Upvotes: 1

Related Questions