Teleporting script won't work,Whats wrong with my teleporting script
I'm making a game so that if you hit the ground you get teleported to another place. My script says that it's fine but in the game, it doesn't work. Here's the script.
I can't figure out what's wrong with this teleportation script. Do you have to add it to the player? Or the ground? Here it is.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Respawn : MonoBehaviour
{
// Start is called before the first frame update
void Awake ()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggersEnter(Collider other)
{
Debug.Log(other.tag);
if (other.tag == "Player")
{
other.transform.position = new Vector3(-9.19f, 1.51f, 0f);
}
}
}
Good day.
IS the OnTriggerEnter methid beeing called?
IS the Debug.Log(other.tag); beeing executed?
Did you read the OnTriggerEnter manual?
OnTriggerEnter is called when the Collider other enters the trigger.
This message is sent to the trigger Collider and the Rigidbody (if any) that the trigger Collider belongs to, and to the Rigidbody (or the Collider if there is no Rigidbody) that touches the trigger.
Notes: Trigger events are only sent if one of the Colliders also has a Rigidbody attached. Trigger events will be sent to disabled $$anonymous$$onoBehaviours, to allow enabling Behaviours in response to collisions. OnTriggerEnter occurs on the FixedUpdate after a collision. The Colliders involved are not guaranteed to be at the point of initial contact.
Note: OnTriggerEnter is not technically part of Collision. It is a $$anonymous$$onoBehaviour function.
Your answer
Follow this Question
Related Questions
Steam VR Teleport Reticle Off Set? 0 Answers
Can't make player character teleport from one side of screen to another. 1 Answer
VR Teleporting on any object 0 Answers
SteamVR Interaction system. Small problem with Teleport points. 3 Answers
is there a way to teleport the player to a certain coordinate right after loading a scene? 0 Answers