I need my player to teleport somewhere when he bumps into a (unity) gameobject with a certain tag (are you seen
) on it. I already found a solution, but then I switched my player's movement to a character controller and now it doesn't work. This is my current script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class found: MonoBehaviour
{
private void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.tag == "are you seen")
{
transform.position = new Vector3(-15.38f, 1.93f, 62.1f);
}
}
}
When you switched to character controller, did you remove the
rigidbody
andcollider
? AnOnTriggerEnter
event still requires the player to have a collider withIsTrigger = true
, and one of the gameobjects to have a rigidbody. Here is what the offical documentation says.