i have a model like temple run,
it will go straight and turn. for now. But how can i say which direction to add force to the player,
it starts with z so in the first turn it shud stop adding force to z and add force to x and in the second turn it shud stop x and add force on -z,
now i dunno how i could do it, i know the addforce scripting but i dunno where to add them,
like if the user presses right arrow it shud go here and smae for left key :shock:
Are you actually adding force via Physics? I would recommend looking into Steering Behaviors and just moving your transform directly. You can simulate forces with a fair degree of accuracy and keep all of your directions local to your object (ie right key will add a steering force that turns the object to his (local) right, left key will do the same on the left side, etc etc).
can you give me a sample code
It’s a huge subject. Do some research independently. Mat Buckland has written several books on AI that talk about steering behaviors. They are immensely valuable.
In the mean time if you want a more basic implementation just keep your directions local to the object you’re moving. So when you hit the right key you turn the object towards its local right (transform.right). When you hit the left key you turn the object towards its local left (transform.left)
ok thanks i will try it out