- Home /
rigidbody.AddForce() is making my character fall over
Hi guys! So I have a character (an animated character, if that helps) and I'm scripting a controller for it (with C#). Here is a bit of it:
if (Input.GetKey (KeyCode.W) || Input.GetKey (KeyCode.UpArrow)) {
animation.Play ("ArmatureAction");
rigidbody.velocity = Vector3.left;
}
However, all this code does is make my character fall over. Why is this happening and how can I fix it? Thanks in advance!
Answer by Metorphium · Oct 10, 2016 at 06:25 PM
You can freeze the needed Rotation Axis of the Rigidbody Component, that way it wont fall over anymore.
Answer by Cherno · Oct 10, 2016 at 06:19 PM
Set the Rigibody's constraints:
especialy the z rotation constraint.
Also take a look at Rigidbody.AddForceAtPosition.
Hi! Sorry for the extremely late reply, but are you the youtuber TheChernoProject?
Answer by Lilius · Oct 10, 2016 at 06:21 PM
You should freeze rotation on X and Z axis on your rigidbody component (unless you sometimes want it to fall over). Check your character rotation also, its sometimes rotated -90 on the x axis if it is done in blender.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Why isn't AddTorque working on this character? 0 Answers
Velocity for movement 0 Answers
Rigidbody player keeps moving after AddForce has stopped? 3 Answers
RigidBody character wont swing? 0 Answers