How to freeze all constraints on rigidbody except transform.forward?
How to freeze all but transform.forward rigidbody constraints? Hi so i'm making an endless runner where the player continuously moves forward along a path and they switch between 3 lanes on the path.
The path contains turns which include going up and down so the axis the player is facing changes a lot.
I am using rigidbody.addforce(transform.forward * speed); to move the player along, but the player will slowly drift along the path side to side which is not what i want.
I want to be able to freeze all rigidbody constraints except for the direction the player is being moved in.
Now i thought of figuring out which way the player is facing by checking the transform.forward then through a bunch of if statements freezing the rigidbody constraints but that seems very inefficient.
Is there a better way?
Also the game is targeted at mobiles if that changes anything.
picture of path:
Your answer
Follow this Question
Related Questions
How to make a cube rotate while moving? 1 Answer
Problems with firing a bullet 0 Answers
Rotation inverts forward direction 0 Answers
Torque rigidbody toward desired rotation on two axes ignoring Y axes? 0 Answers
I have a problem with constraining rotation of rigid bodies connected to hinge joints. 0 Answers