johnnygoodguy2000

PlayerAttackState

Oct 18th, 2025 (edited)
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | Gaming | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class PlayerAttackState : PlayerState
  7. {
  8.     public PlayerAttackState(Player player) : base(player) { }
  9.  
  10.  
  11.  
  12.     public override void Enter()
  13.     {
  14.         base.Enter();
  15.         anim.SetBool("isAttacking", true);
  16.         rb.linearVelocity = new Vector2(0f, rb.linearVelocity.y);
  17.     }
  18.  
  19.     public override void AttackAnimationFinished()
  20.     {
  21.        
  22.         if (Math.Abs(MoveInput.x) > 0.1f)
  23.  
  24.             player.ChangeState(player.moveState);
  25.         else
  26.             player.ChangeState(player.idleState);
  27.        
  28.     }
  29.  
  30.     public override void Exit()
  31.     {
  32.         base.Exit();
  33.         anim.SetBool("isAttacking", false);
  34.     }
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment