Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class HomingAttack : MonoBehaviour
- {
- public bool homingAttackAvailable;
- public bool homingAttackUsed = false;
- private Animator anim;
- private NewPlayerMovement movement;
- // Start is called before the first frame update
- void Start()
- {
- movement = GetComponentInParent<NewPlayerMovement>();
- anim = gameObject.GetComponentInChildren<Animator>();
- }
- // Update is called once per frame
- void Update()
- {
- if (!movement.inAir)
- {
- if (homingAttackUsed)
- {
- ResetHomingAttack();
- homingAttackUsed = false;
- }
- homingAttackAvailable = true;
- }
- if (Input.GetKeyDown(KeyCode.Space) && homingAttackAvailable == true && homingAttackUsed == false)
- {
- homingAttackUsed = true;
- anim.SetBool("Rolling", true);
- }
- }
- public void ResetHomingAttack()
- {
- anim.SetBool("Rolling", false);
- homingAttackUsed = false;
- }
- }
Add Comment
Please, Sign In to add comment