- Home /
Teleport the player from A to B
How can i teleport the player from a to b by pressing "r" without restarting the scene ?
Answer by Stormizin · Jul 28, 2014 at 10:59 PM
First you can Destroy your object from A and instantiate another one on B, binding the hotkey "R".
Just use this guys: Instantiate Destroy Get Button
can i somehow set a position and by pressing "r" teleporting the player there ?
Yes, you can just give the position:
transform.position = new Vector3(X, Y, Z);
Where X,Y,Z is your giving position.
Answer by VesuvianPrime · Jul 29, 2014 at 12:17 AM
Hi Mtasosm
You could try something like this:
public class ExampleClass : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown("R"))
transform.position = UnityEngine.Random.insideUnitSphere * 100;
}
}
that teleports the player to a random position..i want a certain one like respawning by pressing e....but without restarting any data (restarting the scene)
Your answer
Follow this Question
Related Questions
I need to teleport a FPS chara controller 2 Answers
A node in a childnode? 1 Answer
Auto Target Raycast 1 Answer
How to make GUI text disappear after a few seconds? 1 Answer
Infinite Teleport Loop... need to "throw" player out of teleport. 1 Answer