- Home /
Strange rotation
I made a quick character in blender, imported it in unity, put a capsule collider and a rigidbody on it, and now whenever the character hits the terrain where it is uneven, the character starts spinning in all directions. The project file is attached (change the extension to unityproject, I had to change it because it was saying it was an invalid file type).
$$anonymous$$y guess is that the X-Y-Z-axis in Blender are different from those in Unity (i.e. they point in different directions). You may have to rotate the model and export it again, and test until you find the correct orientation of the models axis to Unity's axis.
Or, cheat and put your model as a child in an empty gameObject and use the scripts on the parent (remember, you'll have to put your collider and rigidbody and scripts on the parent gameObject, not the child model). This is just a guess.
I have already rotated the model. Everything works fine until the model is moved towards uneven terrain, at which point the model floats and starts rotating.
Then that would be the rigidbody working? Test this by constraining the rotation on the X and Z axis in the rigidbody inspector.
It appears it is the rigidbody. After constraining the rotation on X and Z, the model only turns in circles on the Y axis. Will having the rotations frozen prevent me from turning the model using scrips?
If you use physics-based stuff like addForce and addTorque then yes. But if you use transform.Rotate then probably not. I really havn't done much physics based stuff, but if I were you I would do a little test. $$anonymous$$ake a script that just rotates the char on one of those axis in an update, if it doesn't rotate, then the constraints do affect transforms. But directly transfor$$anonymous$$g a rigidbody ids not good practice. Perhaps you could lower the center of gravity.
Answer by AlucardJay · Jul 27, 2012 at 03:27 PM
Then that would be the rigidbody working? Test this by constraining the rotation on the X and Z axis in the rigidbody inspector.
If you use physics-based stuff like addForce and addTorque then yes having the rotations frozen prevent you from turning the model using scripts. But if you use transform.Rotate then probably not. I really havn't done much physics based stuff, but if I were you I would do a little test. Make a script that just rotates the char on one of those axis in an update, if it doesn't rotate, then the constraints do affect transforms. But directly transforming a rigidbody ids not good practice. Perhaps you could lower the center of gravity.
A rigidbody uses actual forces. When you modify them without force, the forces that exist get messed up and can have very strange effects.
From the docs :
Scripting
To control your Rigidbodies, you will primarily use scripts to add forces or torque. You do this by calling AddForce() and AddTorque() on the object's Rigidbody. Remember that you shouldn't be directly altering the object's Transform when you are using physics.
source : http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html
Also looking at the script reference, there is no mention of direct transforms in there, raather addForce/Torque and $$anonymous$$ovePosition/Rotation (look under functions) :
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.html
Imagine falling then instantly being thrown in the other direction, your internal organs wouldn't like that :D
There is a good script on character controllers with rigidbody's in the UnifyCommunity wiki, but its down at the moment because silly hackers and spammers have nothing better to do... ( so I can't search and give you the direct link right now, sorry)
When it is back online, search here under controllers (from memory) : http://unifycommunity.com/wiki/index.php?title=Scripts/General
Hope this helps (btw I'm $$anonymous$$ $$anonymous$$ay) =]
Your answer
![](https://koobas.hobune.stream/wayback/20220613074709im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Object mesh collider acting strange 0 Answers
Need help with character unity+blender 1 Answer
2D 360 degress platformer example needed 0 Answers
blender as asset - animation 1 Answer
Proper Physics With Imported FBX Models 0 Answers