//Update movement //The default update all characters should use protected virtual void UpdateVelocity() { if (PauseScreen.IsGamePaused) { //m_Anim.enabled = false; return; } else { //m_Anim.enabled = true; } //Do not move if we are paused (used by other classes to pause the movement) if (m_PausedMovement) { m_AnimatorController.playAnimation(AnimatorPlayers.Animations.Idle); return; } m_IsPlayingSound = false; if (m_IsGrounded) { m_UsingLauncher = false; } //If at any point the jump button is released the player is no longer currently jumping if (InputManager.getJumpUp(m_AcceptInputFrom.ReadInputFrom)) { m_CurrentlyJumping = false; } //Move from other objects first first InstantExternalMovement(); //Launching timers HandleExternalLaunchTimers(); //Initialize states m_IsGrounded = SetIsGrounded(); //Get the projection of the player if (m_ForcedInput == Vector3.zero) { m_Projection = GetInputRelativeToTheCamera(); } else if (m_Projection != m_ForcedInput) { m_Projection = m_ForcedInput; } //If the player is still grounded after the instant movement if (m_IsGrounded) { //Reset any launch movement that reset when we touch the ground ResetGroundedLaunchMovement(); //Check if we should start jumping if (InputManager.getJumpDown(m_AcceptInputFrom.ReadInputFrom) && m_CanJump) { Jump(); AirMovement(); } //Otherwise do normal ground movement, and reset our air movement else { GroundMovement(); } } //If we are not on the ground, we must be airborne, so do air movement else { AirMovement(); } m_CharacterController.Move((m_Velocity + GetLaunchVelocity()) * m_SpeedMultiplier * Time.deltaTime); //m_Anim.Play (m_AnimState.GetAnimation()); }
protected virtual void update() { UpdateTrailRender(); CheckInput(); if (m_Charging) { m_ChargeTimer += Time.deltaTime; ChargingEffect(); // If we have surpassed max charge time then stop charging if (m_ChargeTimer >= m_MaxChargeTime) { m_Charging = false; m_AttackFinished = true; m_Movement.m_PausedMovement = true; } //If we are not still holding the charge button then check if we have surpassed the minimum charge time else if (InputManager.getHeavyAttackUp(m_ReadInput.ReadInputFrom)) { if (m_ChargeTimer > m_MinChargeTime) { m_Charging = false; m_AttackFinished = true; m_Movement.m_PausedMovement = true; } else { Reset(); } } return; } //This is here just to make sure we dont do the slam animation too early, so if we are not grounded yet we will just not continue the logic // If we are in the middle of an air slam if (m_Slamming) { RaycastHit hitInfo; if (!Physics.Raycast(transform.position, Vector3.down, out hitInfo)) { return; } if (hitInfo.distance < 1.0f) { m_Slamming = false; } else { return; } } //If the last attack is finished and we have selected the next attack if (m_AttackFinished && m_ComboSet) { TurnOnTrail(); //Play the animation m_Animator.playAnimation(m_Input); //Flag that we have not selected our next move and we have not finished our attack m_ComboSet = false; m_AttackFinished = false; //Tell the movement it cant jump anymore m_Movement.CanJump(false); //Reset the Safety timer m_AttackSafetyTimer = m_SafetyTime; //If our combo is over then reset the input if (m_ComboFinished) { ResetInput(); } } //If our attack is finished and we have not set a new input by now set the can combo to true //This is here so you can start up a new combo after not having attacked if (m_AttackFinished && !m_ComboSet) { m_CanCombo = true; } if (!m_AttackFinished) { m_AttackSafetyTimer -= Time.deltaTime; if (m_AttackSafetyTimer < 0.0f) { AttackOver(); } } m_IsPlayingSound = false; }