Whenever I try to set the rotation of a unit, it gets blown into the sky. The unit has a collider and a rigidbody.
I try to set the rotation like this:
I get the target like this:
if(Physics.Raycast(posRay, out hit))
if (hit.collider != null)
target = hit.point;
I do not quite understand why the unit I try to move gets violently blown into the sky when I am not even trying to move it, just set the rotation.
You may be rotating it so a part is sticking into the ground. Anytime you move/scale/rotate/Instantiate one object to be illegally interpenetrating another, the physics system gets confused. If they are overlapping by a lot, it tends to blast them apart.
It works better if you do it slowly, like by using RotateTowards. When objects are only are a little bit illegally inside each other, the physics system does a pretty good job of moving/pushing just enough to keep them apart, with no blasting.
Hi, thank you for responding.
I found the problem, it seems the models pivot point was way below the actual representation of the model, and upside down too. So it was trying to flip itself beneath the ground.