// Same as animation, // [Header("Hit FX Impact")] // public SO_ImpactFX sOImpactFX; // private ImpactFX impactFX; // public ImpactFXPool impactFXPool; // private Vector3 hitPosition; public IEnumerator TakeHitAnimation() { // Hit FX. //HitEffect(); // Slow down time. TimeSlow.StartTimeSlow(0.25f); // Set camera nudge backwards from the hit. CameraFollow.CameraNudge_St(normHitDirection, takeHitCamNudge); //StartCoroutine(TimeSlow.SlowTimeScale(5, 0)); // Can be transfered to the update. // Switch this for an Interumpt/Stun, stop all input, attacks, etc. Can also add variables for knockback and stun duration, based on damage received, buffs, damage immunity, etc. // Player cannot move with input. charMov.StopInputMove(); // Player cannot flip. charMov.charCanFlip = false; charMov.FlipSpriteDirectionBased(normHitDirection); // Stops; player attack movement, attack FXs that are stopped on stun, weapon attack motion. When stopping attack with true, player will be interupted but will immediately be able to start a new attack. charAtk.StopAttack(true); // Player weapon does not follow cursor. weapLookAt.lookAtEnabled = false; // // Setup hit animation. timer = 0f; spriteNumber = 0; spriteR.sprite = hitSprites[0]; spriteNumber++; while (timer < getHitDuration) { //print("Should be changing sprite to getting hit in the face sprite."); timer += Time.deltaTime /* /getHitDuration */; if (spriteNumber < hitSprites.Length && timer > hitSpriteTimings[spriteNumber]) { spriteR.sprite = hitSprites[spriteNumber]; spriteNumber++; } yield return(null); } // If health reaches 0, iniate death sequence. if (currentHealth <= 0f) { charDeath.CharacterDies(); } else { charMov.canInputMove = true; //charAtk.atkChain.ready = true; weapLookAt.lookAtEnabled = true; charMov.charCanFlip = true; } }
public void StartMovementSkill() { // Stop the player's current attack. charAttack.StopAttack(false); dashDirection = charMove.normalizedMovement; dashSpeed = dashDistance / dashDuration; // This is just to avoid dividing every update. Example: Time.deltaTime/dashDuration -> Time.deltaTime*multiplierDuration. charMove.canInputMove = false; // Stop player from attacking. // Use and put a charge on cooldown, change the HUD accordingly. UseACharge(); dashing = true; // Request, adjust, and play the dash dust FX sprite animation. spriteAnimObject = spriteAnimPool.RequestSpriteAnimObject(); spriteAnimObject.gameObject.transform.position = charMove.transform.position; if (dashDirection.x < 0) { spriteAnimObject.gameObject.GetComponent <SpriteRenderer>().flipX = true; } else { spriteAnimObject.gameObject.GetComponent <SpriteRenderer>().flipX = false; } spriteAnimObject.StartSpriteAnim(sOSpriteAnimObject); // Start the after image FX. bool flipBool; if (charSpriteTrans.localScale.x >= 0) { flipBool = false; } else { flipBool = true; } afterImageEffect.StartAfterImage(charMove.spriteRend.sprite, flipBool, dashDuration, charMove.transform); StartCoroutine(Dashing()); }