dronkowitz

HomingAttack.cs

May 24th, 2021 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class HomingAttack : MonoBehaviour
  6. {
  7. public bool homingAttackAvailable;
  8. public bool homingAttackUsed = false;
  9. private Animator anim;
  10. private NewPlayerMovement movement;
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14. movement = GetComponentInParent<NewPlayerMovement>();
  15. anim = gameObject.GetComponentInChildren<Animator>();
  16. }
  17.  
  18. // Update is called once per frame
  19. void Update()
  20. {
  21.  
  22.  
  23.  
  24. if (!movement.inAir)
  25. {
  26. if (homingAttackUsed)
  27. {
  28. ResetHomingAttack();
  29. homingAttackUsed = false;
  30. }
  31. homingAttackAvailable = true;
  32.  
  33. }
  34. if (Input.GetKeyDown(KeyCode.Space) && homingAttackAvailable == true && homingAttackUsed == false)
  35. {
  36. homingAttackUsed = true;
  37. anim.SetBool("Rolling", true);
  38. }
  39.  
  40.  
  41. }
  42. public void ResetHomingAttack()
  43. {
  44. anim.SetBool("Rolling", false);
  45.  
  46. homingAttackUsed = false;
  47.  
  48. }
  49. }
  50.  
Add Comment
Please, Sign In to add comment