- Home /
Answer by Mander · Aug 21, 2012 at 09:07 PM
u can save the game objects in a variable when they enter the trigger.
public var position : GameObject[];
var cont : int = 0;
function OnTriggerEnter(hit : Collider){
print("woot");
position[cont] = hit.gameObject;
cont++;
}
remember to assign the number of positions in the inpsector.
Please use proper english, not just the letter u. It really looks untidy.
Answer by Paulo-Henrique025 · Aug 21, 2012 at 08:20 PM
Make a Trigger, when the player enters save its position.
Also, if you know when the race end why not just take the `player.transform.position` there?
Answer by MathieuBarbier · Aug 21, 2012 at 08:37 PM
If you want to know the positions of the "players" of your race you might want to have a variable that inrements during your race with the distance they move (relative to the circuit shape). At the end you compare the values and you'll know each player position. Is that what you want ?
Answer by lasha_an · Aug 21, 2012 at 08:47 PM
i only want know who win when race ends. i think first answer is correct, but i dont know how to save its position
Don't comment creating a new answer!
Vector3 pos = GameObject.FindWithTag("Player").transform.position;
Just don't forget to assign the Player tag to the player.
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
Instantiate bullet towards Player position 1 Answer
swap between 3 gameobjects mid game 0 Answers
Stabilising users view in Unity VR (Fove HMD) 0 Answers
Saving System? 1 Answer