So having collision issues whe simply updating the transfom.position of my gameObject (with a RigidBody component) like so
(pseudo code)
targetGameObjectTransform.position = targetXposition;
My question is, how would I change this so that instead I am using RigidBody.Addforce ?
koirat
2
It’s not that easy.
How much time do we have to move this body ? (one frame ?)
What should be the speed of a body when it is in targetXposition ?
If you want to do it in one frame (physics frame) than:
dTime = Time.fixedDeltaTime
targetXPosition = currentPosition + velocity * dTime +0.5 * acceleration*dTime^2
Solve it for “acceleration” and use it with AddForce ForceMode.Acceleration
Using add force is totally different qpproach to player control, use rigidbody.MovePosition .
Thanks. Yes rigidbody.MovePosition seems to be working.