- Home /
transporting player to gameobject when it collides with different gameobject
I need a script that when the player runs into the enemy gameobject, it takes a life away from the player (in a gui head up display) and when the player reaches 0 lives it transports them to a gameobject at the start and replenishes their lives back to 3. heres what I have so far but its not right for what i want:
var Life = 3;
function OnGUI( ) {
GUI.Box(Rect(350, 35, 120, 30),"Lives:" + Life); }
var otherPlace : Transform;
function OnTriggerEnter(other : Collider) {
var player = GameObject.Find("player");
player.transform.position = otherPlace.position; Life--;
}
Thanks!!
Your answer
Follow this Question
Related Questions
Transform.Position Collision Issue 0 Answers
How can I get a GameObject's transform in game and set that to a variable? 1 Answer
How to move an GameObject to a random position in a defined area? 1 Answer
how to I zero out a parented child's position in X,Y,Z on collision? 1 Answer
Return Enemy To Start Position 1 Answer