//What should this object do when a state is changed ???? protected void SetState(ObjectState state) { switch (state) { case ObjectState.Idle: //Hot fix, so that when the hero respawn, he will not move to his previous position. //Is this one a hot fix or a neccessary logic step ???? navMeshAgent.Stop(); navMeshAgent.SetDestination(transform.position); //Another hot fix, to fix the wrong rotation of object when finishing an animation //There is still a weird rotation sometime but I can not catch it all the time :/ //Debug.Log("Local Rotation " + objectRenderer.gameObject.transform.localRotation.ToString()); objectRenderer.gameObject.transform.localRotation = Quaternion.Euler(Vector3.zero); //Debug.Log("Local Rotation after set - " + objectRenderer.gameObject.transform.localRotation.ToString()); animatorWrapper.AddTriggerToQueue("EnterIdleAnimation"); break; case ObjectState.Run: case ObjectState.Charge: //need this one so the object will not just repeat the run animation while running if (objectState != ObjectState.Run && objectState != ObjectState.Charge) { animatorWrapper.AddTriggerToQueue("EnterMovementAnimation"); } break; case ObjectState.Attack: navMeshAgent.Stop(); animatorWrapper.AddTriggerToQueue("EnterAttackAnimation"); break; case ObjectState.Stun: break; case ObjectState.Special: navMeshAgent.Stop(); animatorWrapper.AddTriggerToQueue("EnterAttackAnimation"); break; case ObjectState.Die: //Maybe special case here ? to add the dead effect here and other stuffs. //Object die while moving, when respawned will have a weird position offset. //This is to fix that bug objectRenderer.OnParentObjectDie(); break; } objectState = state; }
private void ObjectRunning() { if ((transform.position - targetPosition).magnitude <= 0.5f) { //navMeshAgent.Stop(); animatorWrapper.AddTriggerToQueue("EnterIdleAnimation"); objectState = ObjectState.Idle; } }