using UnityEngine; public class Ghost_Scatter : Ghost_behaviour { private void OnDisable() { this.ghost.chase.Enable(); } private void OnTriggerEnter2D(Collider2D other) { Nodes node = other .GetComponent(); if(node != null && this.enabled && !this.ghost.Frightened.enabled) { int index = Random.Range(0, node.availableDirections.Count); if(node.availableDirections[index] == -this.ghost.movement.direction && node.availableDirections.Count > 1) { index++; if(index >= node.availableDirections.Count) { index = 0; } } this.ghost.movement.SetDirection(node.availableDirections[index]); } } }