void Awake() { lookState = LOOKSTATE.IDLE; Self = transform.parent; lr = true; aimedRotation = Quaternion.Euler(0, idleLookAngle, 0); currentTriggerRot = transform.rotation; }
void executeLookAt() { if (Quaternion.Angle(currentTriggerRot, transform.rotation) > lookDirAcc) { transform.rotation = Quaternion.Slerp(transform.rotation, currentTriggerRot, Time.deltaTime * lookSpeed); } else { currentTriggerRot = transform.rotation; lookState = LOOKSTATE.NONE; } }
void return2Idle() { lr = true; aimedRotation = Quaternion.Euler(0, idleLookAngle, 0); if (Quaternion.Angle(Self.rotation, transform.rotation) > lookDirAcc) { transform.rotation = Quaternion.Slerp(transform.rotation, Self.rotation, lookSpeed * Time.deltaTime); } else { lookState = LOOKSTATE.IDLE; } }
// initiate the action to look at a certain position and setting the corresponding lookState public void LookAt(Vector3 pos, LOOKSTATE lookStateIn) { if (lookStateIn == LOOKSTATE.LOOKAT || lookStateIn == LOOKSTATE.TRIGGERED) { lookState = lookStateIn; currentTriggerRot = Quaternion.LookRotation(pos - transform.position); } else { Debug.Log("There was an attempt to set an invalid lookState for E" + Self.GetComponent <EnemyBrain>().enemyIndex.ToString()); } }
//function to call once the view direction is change public void ChangeLookDirection(LOOKSTATE newLookState) { time = 0; lookState = newLookState; }
//function to make unit look at front view public void LookMiddle() { lookState = LOOKSTATE.MIDDLE; }