top of page
Search

Melee weapons

  • Writer: Keshav Batra
    Keshav Batra
  • Mar 12, 2021
  • 1 min read

So I've been thinking about how I want my melee weapon to hit and after some help from some teachers, I finally figured it out. Below is the final result:




Melee Code

{

// Variables;

public Animator anim;

private void Start()

{

//anim = GetComponent<Animator>();

}


// Update is called once per frame

private void Update()

{

//if (Input.GetButtonDown("Fire1"))

//anim.SetBool("attacking", true);

//else if (Input.GetButtonUp("Fire 1"))

//anim.SetBool("attacking", false);

if (Input.GetKeyDown(KeyCode.M))

{

anim.SetBool("WeaponMelee", true);

StartCoroutine(Delay());

}

}


IEnumerator Delay()

{

yield return new WaitForSeconds(0.9f);

anim.SetBool("WeaponMelee", false);

}

}


 
 
 

Comments


bottom of page