Hi all,
I m creating one car race game when my car hit the side walls its getting struck i want to set my car position back to its previous position how to do that can any one help me
please
thanks
Hi all,
I m creating one car race game when my car hit the side walls its getting struck i want to set my car position back to its previous position how to do that can any one help me
please
thanks
In your game script, have a variable that keeps the position of the car. In Update() decide if the car is still under control or not. If it is under control, then update the variable. If the car is skidding or crashing then don’t update the variable. If the car has finally crashed and come to a halt, then change the position of the car to the last one you stored. In pseudo-code:
Update() {
if car is under control
last_position = position;
if car is skidding or crashing
play some kind of warning sound
if car has crashed
let player know to drive more slowly
position = last_position
}
Note - this is not Javascript or c# - it is meant to illustrate the logic you will need to implement.