public void PerformAction() { Vector3 destination; if (tracingDestination) { destination = SGGameManager.Instance.CurrentMonsterDestination.position; } else { destination = SGGameManager.Instance.hero.transform.position; } me.RotateToLookup((me.transform.position - destination).normalized, rotationSpeed); var acc = -me.transform.up * me.moveSpeed * Time.deltaTime; var vertical = Vector2.Dot(me.body.velocity + (Vector2)acc, me.transform.up) * (1 - Time.deltaTime * damp); var horizontal = Vector2.Dot(me.body.velocity + (Vector2)acc, me.transform.right) * (1 - Time.deltaTime * damp * 2); me.body.velocity = me.transform.up * vertical + me.transform.right * horizontal; }
public void PerformAction() { if (actionState == SGE_MONSTER_ACTION_STATE.TRACE_DESTINATION || actionState == SGE_MONSTER_ACTION_STATE.TRACE_HERO) { Vector3 destination = Vector3.zero; if (actionState == SGE_MONSTER_ACTION_STATE.TRACE_DESTINATION) { destination = SGGameManager.Instance.CurrentMonsterDestination.position; } else if (actionState == SGE_MONSTER_ACTION_STATE.TRACE_HERO) { destination = SGGameManager.Instance.hero.transform.position; } me.RotateToLookup((me.transform.position - destination).normalized); me.body.velocity = (destination - me.transform.position).normalized * me.currentMoveSpeed; } else { me.myAnimator.SetTrigger("Attack"); } }