How can I draw trajectory of RigidBody2D (ignoring any collisions). I have set RigidBody2D’s linear and angular damping to 0 and mode to replace. And drew the path using s = ut + 0.5at^2. For some reason the actual trajectory falls behind the calculated one. what could be the problem here.
Yeah I have gravity and a in that motion formula is gravity (Vector2(0, 980)). And I did nothing but set RigidBody2D’s damping (linear and angular) mode to replace. So the material is default value.
What are u and t?
If the trajectory height is a function of the x-position, you need to divide by the rigidbody’s horizontal velocity because the faster it goes, the less it will fall per distance travelled
s = ut + 0.5at^2 is physics formula for displacement under an acceleration. Here s is displacement u is initial velocity a is acceleration (in this case gravity) and t is time which I use as 1/60
How are you plotting the trajectory of an objecting using only one dimension? Your plot should be x, the horizontal position , and s, the vertical position.
For now I am testing to see whether I can predict the trajectory. For that I am placing the RigidBody2D (with collision shape rectangle) bottom left of the screen and set linear velocity up right direction.
I have found the problem. When the engine calculating there is error in precision because of floats I guess. But because I am using formula there is hardly any error. Which causes real trajectory to fall behind. So I had to calculate manually frame by frame using delta as 1/frame_rate.