Hey everyone! I have made a teleporting script and it works perfectly with the player. So when the player collides with the object tagged "teleportPad" it teleports to a game object specified. No problems there. I don't want the player to teleport though, I want an enemy mesh to teleport when it collides with the player mesh but it won't work. There aren't any reported errors too. Here's my code:
using UnityEngine;
using System.Collections;
public class Teleport : MonoBehaviour {
public Transform destination;
void OnControllerColliderHit(ControllerColliderHit col) {
if(col.collider.gameObject.tag == "teleportPad"){
transform.position = destination.position;
}
}
}
So basically how do I make this code work when the player collides with the enemy and then the enemy teleports. Thanks!
↧