#can someone help me fix this code?

1 messages · Page 1 of 1 (latest)

neon steppe
#

every time I shoot it doesn't play the animation

#

the code is
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, Range))
{
Debug.Log(hit.transform.name);

 animator.SetBool("Shoot", true);

 new WaitForSeconds(1f);

 animator.SetBool("Shoot", false);

 TakeDamage Target = hit.transform.GetComponent<TakeDamage>();
if (Target != null)
 {
     Target.takedamage(Damage);
 }

 GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
 Destroy(impactGO, 2F);
solemn flame
#

new WaitForSeconds(1f);

What made you think this would do anything?

twilit folio
#

Also why wait in the first place?
If you have an animation you need to play only once, use a trigger, not a bool.

neon steppe
#

Okay thanks for all the feedback, and i just started coding and im not really sure about all of the coding

solemn flame
#

if you are new to coding, you should not be using unity right now