public void Strike() { //RESET TIMER timer = 0f; Debug.Log("Bam"); //Play bat sfx //batAudio.Play(); //Stop the particles from playing if they were, then start the particles. FIX //batParticles.Stop(); //batParticles.Play(); batLine.enabled = true; batLine.SetPosition(0, transform.position); batRay.origin = transform.position; batRay.direction = transform.forward; //Perform raycast against game objects on the hittable layer if the hit happens if (Physics.Raycast(batRay, out batHit, range, hittableMask)) { //Play bat sfx anim.SetTrigger("SwingBat"); batAudio.Play(); //Try to find EnemyHealth script on hit gameobject EnemyHealth enemyHealth = batHit.collider.GetComponent <EnemyHealth>(); if (enemyHealth != null) { //Enable light batLight.enabled = true; enemyHealth.GetHitByBat(batDamage, batHit.point); } //Try to find NPCTrigger script NPCTrigger npcTrigger = batHit.collider.GetComponent <NPCTrigger>(); if (npcTrigger != null) { npcTrigger.GetTalkedTo(); } batLine.SetPosition(1, batHit.point); } else { //set the second position of the line renderer to the fullest extent of the bat's range. batLine.SetPosition(1, batRay.origin + batRay.direction * range); anim.SetTrigger("SwingBat"); } }
// Start is called before the first frame update void Start() { trigger = FindObjectOfType<NPCTrigger>(); NPCanim = GetComponent<Animator>(); transform.position = waypoints[waypointIndex].transform.position; }