So I have an object (crate) that I want to move around on top of another object (ship).
I want the crate to accelerate up to (desiredVelocity - velocity), moving it across the ship’s deck.
I also want to add the ship’s velocity to the crate, so it will move along with the ship.
Right now I’m using this:
Vector3 velocityChange (desiredVelocity + shipVelocity - velocity);
rigidbody.AddForce(velocityChange,ForceMode.Acceleration);
This works, but it has to accelerate up to shipVelocity. So when the ship starts moving, there’s some lag time before the crate starts moving. I decided to try ForceMode.Impulse, and that adds the ship’s velocity instantly, but also makes the crate accelerate to desiredVelocity instantly.
So I’ve tried doing (desiredVelocity - velocity)*Time.deltaTime + (shipVelocity - velocity), with impulse mode, and it accelerates right, but shipVelocity is added waaaay too much.
I know I’m probably missing something really simple like I usually do. Might someone else have an idea about how to do this?