- Home /
How do I lock movement to Axis even if player is effected by object
Hi I am extremely new to unity am trying to make a simple game where a board moves back and fourth along the X-Axis and hits a jump in the middle of the level. My problem is when the board hits the jump it not only propels the board in the air but it moves along the Z-axis making the board out of place to hit the jump a second time from the opposite direction. Is there any way to lock the board preventing it from moving on the Z-axis while in the air? Thank you for your help!
Heres a picture of the game if it helps give you a better idea. http://gyazo.com/38e1b9e8e04525d673f278c377e8c7f1
Answer by Baste · May 12, 2015 at 10:42 AM
The rigidbody component has a Constraints-part, where you can freeze the position and rotation on any axis.
That will cause the rigidbody to ignore outside forces that would move it in those ways - so if you freeze y-rotation, hitting stuff won't rotate it over the y-axis. The rigidbody can still be rotated by scripts, though.
Very nice indeed. Was having the same problem. I was hesitant on the constraints. Thinking that would block my controller script!
Your answer
Follow this Question
Related Questions
Why does the player keep pointing in a specific direction after moving? 0 Answers
Constrain axis of isometric camera ("vertical" only) 0 Answers
Animation Co-ordinates not being followed exactly(Solved) 1 Answer
Can't get character to Jump on the Y Axis (C#) 2 Answers
Clamping movement range on X-axis 0 Answers