Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Teleporting Script Doesn't Work With Anything But The Player

$
0
0
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!

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>