I'm creating a game, and i need that when the FPC collide with the object "enemy", the FPC return the start position.
I tought this would be a simple task, but after I tried the following code, and it didnt work, I just dont know what to do anymore.
function OnControllerColliderHit(hit:ControllerColliderHit)
{
if ((hit.gameObject.tag == "enemy"))
{
transform.position = new Vector3(7,1,93);
Debug.Log(transform.position);
}
}
If anyone can help me, I will be very gratefull,
Thx for your time,
Anderson
I tried this script but it did not work, my teacher taught me this script.but now I do not collide with the character I go with him and that I teleport to the start point.
function OnTriggerEnter(hit:Collider)
{
if ((hit.gameObject.tag == "enemy"))
{
Debug.Log(transform.position);
var go : GameObject = GameObject.FindWithTag("respawn");
transform.position.x = go.transform.position.x;
transform.position.y = go.transform.position.y;
transform.position.z = go.transform.position.z;
}
}