Created
May 18, 2021 13:55
-
-
Save giftheck/108306e6b9a7f09d8512670c1acc08b2 to your computer and use it in GitHub Desktop.
Column Tales
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| public class HorizontalMovementDisabler : MonoBehaviour | |
| { | |
| public GameObject columnObject; //Object the rotation script is attached to | |
| public string scriptName; //The name of the script | |
| private void OnTriggerEnter(Collider other) | |
| { | |
| if (other.tag == "Environment") | |
| { | |
| Debug.Log("Trigger picked up an environment collision"); | |
| StopRotation(); | |
| } | |
| else if (other.tag == "Enemy") | |
| { | |
| Debug.Log("Trigger picked up an enemy collision"); | |
| StopRotation(); | |
| } | |
| else if (other.tag == "Obstacle") | |
| { | |
| Debug.Log("Trigger picked up an obstacle collision"); | |
| StopRotation(); | |
| } | |
| else | |
| { | |
| Debug.Log("Trigger did not pick up a collision that needed to be detected"); | |
| StartRotation(); | |
| } | |
| } | |
| private void OnTriggerExit(Collider other) | |
| { | |
| Debug.Log("Object exited the trigger, rotation restarted"); | |
| StartRotation(); | |
| } | |
| private void StopRotation() | |
| { | |
| (columnObject.GetComponent(scriptName) as MonoBehaviour).enabled = false; | |
| } | |
| private void StartRotation() | |
| { | |
| (columnObject.GetComponent(scriptName) as MonoBehaviour).enabled = true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment