- Home /
Question by
Wesker_Kai · Apr 19, 2012 at 03:18 PM ·
collisionphysicstriggerrespawn
If trigger hit, spawn it
Hi All Guys! nice to meet you from the net.
I am trying to make a easy game which is if a ball(TAG AS PLAYER) hit the pipe(TAG AS ENEMY), it will return to the stating point.
The pipe have collider component and the ball also. Should I need to tick the trigger box?
How can I write the script in C# about that? I am quite confused about that, plz help me.
Comment
Best Answer
Answer by fafase · Apr 19, 2012 at 04:00 PM
function OnCollisionEnter(other:Collision){
if(other.gameObject.tag=="enemy"){
transform.position=Vector3(0,0,0);}}
Attach that to the player. That consider that 0,0,0 is the origin of your game.
IsTrigger means you want to ignore physics meaning that the object won't bounce. In your case that won't change much since you are respawning your guy.