public void Move(Vector3 move) { // convert the world relative moveInput vector into a local-relative // turn amount and forward amount required to head in the desired // direction. if (move.magnitude > 1f) { move.Normalize(); } move = transform.InverseTransformDirection(move); CheckGroundStatus(); move = Vector3.ProjectOnPlane(move, m_GroundNormal); m_TurnAmount = Mathf.Atan2(move.x, move.z); m_ForwardAmount = move.z; ApplyExtraTurnRotation(); // control and velocity handling is different when grounded and airborne: if (m_IsGrounded) { if (m_Animator.GetBool("InteractNow")) { InteractNow(); m_Animator.SetBool("InteractNow", false); } else { if (interact) { UpdateNearestTarget(); //esto actualiza el target, sino no lo hace if (!(target == null)) { interact = IsInTarget(); } else { interact = false; } } if (!m_Animator.GetBool("AttackEnded") || playerCombat.GetInAttack()) //in attack { if (!playerCombat.GetInAttack() && !m_Animator.GetBool("AttackEnded")) //start attack { playerCombat.SetInAttack(true); playerCombat.ActivateDemoAttackWeapon(); } else { if (playerCombat.GetInAttack() && m_Animator.GetBool("AttackEnded")) //attack ended { playerCombat.SetInAttack(false); playerCombat.ActivateDemoWeapon(); } else //in attack anim { if (!m_Animator.GetBool("AttackEnded") && playerCombat.GetIsAttacking() && playerCombat.GetWeaponHitbox().GetHitted()) //this controls the attack phase, doing damage if is necesary { if (playerCombat.GetAttackID() != m_Animator.GetInteger("AttackID")) //if this enemy dont has attack yet { playerCombat.GetWeaponHitbox().GetHittedEnemy().GetComponentInParent <EnemyCombat>().ChangeStats(CombatStats.CombatStatsType.HP, -playerCombat.GetDamage()); //do damage playerCombat.SetAttackID(m_Animator.GetInteger("AttackID")); playerCombat.GetWeaponHitbox().GetHittedEnemy().GetComponentInParent <EnemyCombat>().SetEnemyLastAttackID(playerCombat.GetAttackID()); } else { if (playerCombat.GetAttackID() != playerCombat.GetWeaponHitbox().GetHittedEnemy().GetComponentInParent <EnemyCombat>().GetEnemyLastAttackID()) { playerCombat.GetWeaponHitbox().GetHittedEnemy().GetComponentInParent <EnemyCombat>().ChangeStats(CombatStats.CombatStatsType.HP, -playerCombat.GetDamage()); playerCombat.GetWeaponHitbox().GetHittedEnemy().GetComponentInParent <EnemyCombat>().SetEnemyLastAttackID(playerCombat.GetAttackID()); //if we hit 2 enemies we have this case } else { //mismo problema nombrado que en la clase skeleton } } } } } } if (!interact) { HandleGroundedMovement(jump, m_Animator.GetBool("RunDisabled")); } } } else { HandleAirborneMovement(); } // send input and other state parameters to the animator UpdateAnimator(move); }