Hello,
I know transform.Translate doesn’t use physics, but Rigidbody.MovePosition does, but it moves the object to the desired position. I have to add the movement coordinates to transform.position, and give it as my argument to Rigidbody.MovePosition in order for my object to move in physics, but noticed it doesn’t move according to ‘translation’. Is there a function in Rigidbody for that? Also, what is the transform.Rotate version of Rigidbody.MoveRotation? Thank you.
The way you’re expressing stuff makes it hard to pin down what you mean.
Move a body relative to its current position.
myBody.MovePosition(myBody.position + translation);
Rotate a body relative to its current rotation.
myBody.MoveRotation(myBody.rotation * rotation);
Please don’t cross-post: transform.Translate and tranform.Rotate version of Rigidbody.MovePosition and Rigidbody.MoveRotation
transform.Translate moves the object based on the object’s eulerAngle, where Rigidbody.MovePosition attempts to move the object to a certain position (IF there are no colliders in the way). I would like the position to be based on the object’s eulerAngle (as if it is ‘translating’, BUT with physics). I also want to do the same for rotation.
It’s nothing to do with “eulerAngle”. It moves it in the space you select. Yes, the default option is self which is local-space. You didn’t indicate that was what you wanted. Again, it’s the way you’re describing things.
So what you’re asking about is how to rotate a local-space vector by a rotation to give a world-space vector, the vector being the translation and the rotation the body rotation i.e. “transform.TransformDirection(translation)” so:
myBody.MovePosition(myBody.position + transform.TransformDirection(translation));
I’ve given you the rotation above. Rotation is a Quaternion that is the relative rotation you want.
Thank you. It works.