// Use this for initialization void Start() { topStuckCheck = transform.Find("TopStuckCheck"); leftStuckCheck = transform.Find("LeftStuckCheck"); rightStuckCheck = transform.Find("RightStuckCheck"); playerController = GetComponent <BoxyControl>(); }
void OnTriggerEnter2D(Collider2D other) { // If the player enters the trigger zone... if (other.tag == "Player") { BoxyControl playerController = other.GetComponent <BoxyControl>(); if (playerController.HandleGetCoin(color)) { // Destroy me Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D other) { // If the player enters the trigger zone... if (other.tag == "Player") { BoxyControl playerController = other.GetComponent <BoxyControl>(); playerController.Die(); // disable collision by destroying myself. Pretty hacky. if (hazardClass == HazardClass.Invisible) { Destroy(transform.root.gameObject); } } }
public Transform player; // Reference to the player's transform. void Awake() { // Setting up the reference. playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <BoxyControl>(); player = GameObject.FindGameObjectWithTag("Player").transform; }