- Home /
How to move forward automatically while limiting the horizontal and vertical movement
I am trying to make a Star Fox-esque game for a school final project where the character moves forward automatically but is restricted on how far horizontal or vertical it can go. Currently how I have achieved this is with 4 Box Colliders placed in a "+" shape so the character will travel in between all of the colliders. This works to an extent, the problem is when I collide with the box colliders I lose all forward motion.
This is the code I am using to make the character go forward
function Update () {
rigidbody.AddRelativeForce(0,0,2.5);
}
How would I go about limiting the players horizontal and vertical movements without stopping whenever I hit the Box Colliders?
Answer by idunlop_oefun · Dec 08, 2012 at 04:48 AM
Add a Physics Material to your rigidbody and box colliders where the friction is zero.
Your answer

Follow this Question
Related Questions
How would I make it so that my character moves only so fast 1 Answer
How to lerp back and forth? (ex. platform) 2 Answers
How to have vertical and horizontal axis work at the same time 1 Answer
Double Clicking Horizontal/Vertical Axis 1 Answer
move character controller forward using gui button. 1 Answer