- Home /
Question by
SerujiShard · Nov 09, 2018 at 09:35 PM ·
3drespawnteleportteleportingrespawning
Teleport (Respawn) is Not Working in a 3D Project.
My problem is the following: I have created this Script and for some unknown reason I do not teleport the Player to its destination, I have placed an invisible floor where the Player can fall and be transported to the starting point.
public Transform respawnTarget;
public GameObject thePlayer;
void OnTriggerEnter(Collider other)
{
thePlayer.transform.position = respawnTarget.transform.position;
}
}
Comment
Best Answer
Answer by hectorux · Nov 10, 2018 at 12:22 AM
Does your plane have a rigidbody? or your player? the one that have that script must have it, also one of them must have checked the trigger box in the collider component
Answer by AaronXRDev · Nov 09, 2018 at 10:06 PM
I think what is happening is that one of your items is a Transform and the other is a GameObject.
Try this:
public Transform respawnTarget;
public GameObject thePlayer;
void OnTriggerEnter(Collider other)
{
thePlayer.transform.position = respawnTarget.position;
}