Quantcast
Channel: Questions in topic: "portals"
Viewing all articles
Browse latest Browse all 85

A way to code teleporters for different teams?

$
0
0
Hi all, I'm having issues with the attached script. My players are instantiated under the tag "PlayerBlue" or "PlayerRed" according to which team the user selects. However, I can only seem to get one teleporting script into the game, as duplicating it and adding a "1" or something at the end just doesn't work for me. Is there any way I could just allow both tags to pass through the teleporters, but only allow blue to pass through blue and red to pass through red? The teleporters end in a neutrally-accessible place and would cause problems if the other team could get through. I hope I was clear with this issue, thanks! using UnityEngine; public class Teleporter : MonoBehaviour { public bool teleported = false; public Teleporter destination; void OnTriggerEnter(Collider c) { if (c.CompareTag("BlueTeam")) { if (!teleported) { destination.teleported = true; c.gameObject.transform.position = destination.gameObject.transform.position; } } } void OnTriggerExit(Collider c) { if (c.CompareTag("BlueTeam")) { teleported = false; } } }

Viewing all articles
Browse latest Browse all 85

Trending Articles



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