Right now I have an if statement for an OnCollisionEnter with a wall and inside it I need to code it so that the player will be moved from one point to another, much like hitting a trigger for ending the level and starting the player in another level. The trigger Object I have set up now is a wall. Please help me! I am also using C# scripts.
Is it like a teleporter? If so, you could create an empty object and place it at the destination point, and use something like this in the trigger script:
public Transform dest; // drag here an empty object that marks the destination point void OnTriggerEnter(Collider other){ if (other.tag == "Player"){ // remember to tag the player as "Player"! other.transform.position = dest.position; other.transform.rotation = dest.rotation; } }
Notice that the dest object defines position and rotation, thus remember to define its forward direction to where you want the player to be looking at when teleported.
Alright, thanks for the response. I will try it out and reply on how it goes.
public Transform dest; // drag here an empty object that marks the destination point
What exactly do you mean by this? Sorry about these types of questions but I am new to using Unity and C# scripting.
Can anyone give any suggestions?