Frequently moving Kinematic bodies not colliding with Dynamic bodies #330
-
Hello I have a number of planets that orbit a sun. The position is set each frame by updating Pose.Position. The player (a Dynamic body) is attracted towards planets by applying a small velocity on each frame. The problem is, if the planet's orbit is going toward the player body it will not collide with the planet. However collisions work fine when the planet is moving away from the dynamic object. I'm assuming that the Pose.Position change is teleporting the planet over the player dyanmic object and causing issues. What's the best way to do this? Is there a way to force a collision if/when player goes into planet? Many thanks PS: A lot of of the other game logic is based around knowing where the planet will be at any frame ( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That sounds like it is indeed because of teleporting the body. Setting the velocity should resolve the collision issues. While tiny numerical error will arise, it won't accumulate over many frames if the velocity is set by simply using If desired, you could also simply set the position after the end of the timestep so that the position is bitwise identical to your target. |
Beta Was this translation helpful? Give feedback.
That sounds like it is indeed because of teleporting the body. Setting the velocity should resolve the collision issues.
While tiny numerical error will arise, it won't accumulate over many frames if the velocity is set by simply using
(targetPosition - currentPosition) / dt
, wheretargetPosition
is where you want the body to be after the timestep anddt
is the timestep duration.If desired, you could also simply set the position after the end of the timestep so that the position is bitwise identical to your target.