- Home /
Can I arbitrarily move a dynamic Rigidbody 2D?
Hi I´m really new here.
I want to make some 2D objects that are affected by gravity. Think air-filled balloons that you can bat up to the ceiling and then they gently float down again.
But I also want them to be affected by variable winds that might blow them left or right, random events that might kickstart them into moving somewhere else, and later, on a touch screen, user gestures moving them somewhere else and etc., etc.
If I want gravity, I should use dynamic Rigidbody 2D. But the documentation says:
"Do not use the Transform component to
set the position or rotation of a
Dynamic Rigidbody 2D. The simulation
repositions a Dynamic Rigidbody 2D
according to its velocity; you can
change this directly via forces
applied to it by scripts, or
indirectly via collisions and
gravity."
So does that mean I should only affect them via velocity, that I can´t timewarp them to a different position?
Answer by grizzly48 · Feb 17, 2018 at 05:03 PM
No, as far as I understood it, it only means, that you call "Rigidbody2D.MovePosition(Vector2 newPosition)" instead of "Transform.position = Vector2 newPosition" (https://docs.unity3d.com/ScriptReference/Rigidbody2D.MovePosition.html) and the same goes for rotation, simply use the method of the rigidbody instead of manipulating the transform directly. Hope that helps