- Home /
Dose any one know how to send object current postion to preivues posistion
Hi all,
I m using car and car track when the car hits the sidewall collider that time it getting struck i want to send car back to its previous postion
please help me
thanks in advance
Answer by Montraydavis · Nov 16, 2012 at 12:44 PM
You just need to create a Vector3, and store the position, in which this case is a "checkpoint". Something like this would work.
var checkpoint : Vector3 = Vector3.zero ;
function Start ( ) {
checkpoint = transform.position ;
}
//Move the code from start to whenever you want to set this "checkpoint". From there on, you just need to set the position whenever gets hit .
function OnCollisionEnter ( collision : Collision ){
if ( collision.collider.tag == "EnemyOrObjectName" )
{
transform.position = checkpoint ;
}
}
Attach that script to your 'car'. Good luck, and I hope this helped.
PS: Please let me know if this does not work for you, and I will approve it, and hopefully others can give some insight on the issue.
~Thanks for using Unity3D.
Thanks for quick replay... my car is starting form start postion when it hit collider i want to start from their only after some distance form collider
Your answer
Follow this Question
Related Questions
How to set current position to previous postion 1 Answer
Camera rotation around player while following. 6 Answers
unity game 1 Answer
Teleporting Player to a point using box colliders 1 Answer
Internal collisions 1 Answer