Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

BennyKw99

Newbie
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About BennyKw99

  • Rank
    Newbie
  • Birthday 08/03/1999
  1. so I added an enemy in fps kit v1.6 when I shot it on the enemy it did not receive damage even though the enemy was given a script. sorry if my english is not good zombieControiller.cs using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class zombieControiller : MonoBehaviour { NavMeshAgent nav; Transform player; Animator controller; float health; GameManagement game; CapsuleCollider capsuleCollider; Animator anim; bool isDeath = false; // Use this for initialization void Start() { nav = GetComponent<NavMeshAgent> (); player = GameObject.FindGameObjectWithTag("Player").transform; controller = GetComponentInParent<Animator>(); game = FindObjectOfType<GameManagement>(); health = 20 + (1.25F * game.round); capsuleCollider = GetComponent<CapsuleCollider>(); anim = GetComponent<Animator>(); } // Update is called once per frame void Update () { if (isDeath) { nav.SetDestination(player.position); controller.SetFloat("speed", Mathf.Abs(nav.velocity.x) + Mathf.Abs(nav.velocity.z)); } } void ApplyDamage(float damage) { health -= damage; if (health <= 0) Death(); } void Death() { isDeath = true; nav.Stop(); capsuleCollider.isTrigger = true; anim.SetTrigger("isDeath"); Destroy(gameObject, 4f); } }
×
×
  • Create New...