- Home /
how to reset the position after collision
I m making a car game and when it hit on the wall it get stucked and I have to move it back to drive. I mean I cannot turn it. Is there any way so that I can set its position so that I dont have to drive it back to turn. Really needed. Thanx in advance guys....
I ve moved it using input.getaxis("vertical") and input.getaxis("horizontal"). It moves will but when it collide with the wall it get stuck and I have to drive back and turn n thats my prob.. Can I set its position in such way that after collision it appers in such way that I dont have to drive back.. Like most in car game..
So you're using something like http://docs.unity3d.com/Documentation/ScriptReference/Input.GetAxis.html via .translate ?
If that's the case and your object has a rigidBody attached, then you'r probably just messing up the physics engine and the rigidBody gets stuck in the wall.. in that case you probably would want to use .AddForce to move the car and not .translate..
have a look at
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html and http://unity3d.com/learn/tutorials/modules/beginner/physics/addforce
Answer by Berenger · Mar 19, 2014 at 08:21 AM
Record periodically (each seconds ?) the position of the car if it is a valid one => if you fell off a cliff, it is not a valid position. You could do that with a Physics.OverlapSphere for obstacles I guess.
When you're stuck inside a wall, reset to the last valid position.
Your answer
Follow this Question
Related Questions
UnityCar + Realistic FPS Prefab problems 0 Answers
Error CS0246 with UnityCar help ! 2 Answers
unitycar2.1 mobile vs axis car controller 0 Answers