Spawning a player to a new place in the same level
I have a game where the player touches a object tagged as "teleporter" and ive got them to both vanish upon the player contacting with the teleporter.
I want the player to respawn in a new location i have marked with a game object called "transportspot1"
this is the code for confirmation the teleporter works:
public class Teleportation : MonoBehaviour { private int Transportspot1;
void OnTriggerEnter(Collider other){
{
if (other.gameObject.CompareTag ("Player"))
print ("Teleport Successful");
}
}
}
that is attached to the "teleporter" object
i need to make the player move to "transportspot1", which is on a different area of the same level, when the Player object collides with the teleporter, can anyone help?
@Nosmo You can use it for the object movement.
http://docs.unity3d.com/ScriptReference/Vector3.$$anonymous$$oveTowards.html
Answer by PrisVas · Jun 28, 2016 at 05:37 PM
void OnTriggerEnter(Collider other){
{
if (other.gameObject.CompareTag ("Player"))
{
GameObject transportspot1 = GameObject.Find("transportspot1");
other.transform.position = transportspot1.transform.position;
}
print ("Teleport Successful");
}
}