// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { abc = animator.gameObject.GetComponent <ASCLBasicController>(); }
void Start() { ASCLBasicController abc = Transform.FindObjectOfType(typeof(ASCLBasicController)) as ASCLBasicController; target = abc.transform; }
void Start() { allZones = FindObjectsOfType(typeof(Zone)) as Zone[]; enemies = FindObjectsOfType(typeof(EnemyController)) as EnemyController[]; envTargets = FindObjectsOfType(typeof(EnvTarget)) as EnvTarget[]; abc = Transform.FindObjectOfType(typeof(ASCLBasicController)) as ASCLBasicController; player = abc.transform; mouseCam = Camera.main.GetComponentInChildren <MouseOrbit>(); //we're going to loop through all the zones to find out where we are bool foundFloor = false; ///declaring it here because we use it elsewhere as well float closest = 210.0f; //same for this RaycastHit hit = new RaycastHit(); Ray ray = new Ray(); ray.origin = player.transform.position; ray.direction = -player.transform.up; for (int i = 0; i < allZones.Length; i++) { for (int f = 0; f < allZones[i].floors.Count; f++) { //If a floor is the closest... if (allZones[i].floors[f].Raycast(ray, out hit, 500)) { float dist = Vector3.Distance(hit.point, ray.origin); if (!foundFloor) { closest = dist; foundFloor = true; abc.floorPlane = allZones[i].floors[f]; abc.currentZone = allZones[i]; } if (dist <= closest) { closest = dist; abc.floorPlane = allZones[i].floors[f]; abc.currentZone = allZones[i]; } } } } for (int e = 0; e < enemies.Length; e++) { foundFloor = false; ///declaring it here because we use it elsewhere as well closest = 210.0f; //same for this hit = new RaycastHit(); ray = new Ray(); ray.origin = enemies[e].transform.position; ray.direction = -enemies[e].transform.up; for (int i = 0; i < allZones.Length; i++) { for (int f = 0; f < allZones[i].floors.Count; f++) { //If a floor is the closest... if (allZones[i].floors[f].Raycast(ray, out hit, 500)) { float dist = Vector3.Distance(hit.point, ray.origin); if (!foundFloor) { closest = dist; foundFloor = true; enemies[e].floorPlane = allZones[i].floors[f]; enemies[e].currentZone = allZones[i]; } if (dist <= closest) { closest = dist; enemies[e].floorPlane = allZones[i].floors[f]; enemies[e].currentZone = allZones[i]; } } } } } foreach (Zone zone in allZones) //for some wacko reason you cannot place this in the below loop, fails to init in time { zone.collider.enabled = true; } foreach (Zone zone in allZones) { foreach (EnvTarget target in envTargets) { if (zone.collider.bounds.Contains(target.transform.position)) { target.zone = zone; } } } foreach (Zone zone in allZones) //for some wacko reason you cannot place this in the above loop, fails to init in time { zone.collider.enabled = false; } }