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.

Lasheen

Newbie
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Lasheen

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  • Location:
    sri lanka

Recent Profile Visitors

312 profile views
  1. help me to fix that error SendMessage ApplyDamage has no receiver! UnityEngine.Component:SendMessage(String, Object) NewZombieAI:Update() (at Assets/New folder (9)/NewZombieAI.cs:83) This is my NewZombie cs File using UnityEngine; using System.Collections; public class NewZombieAI : MonoBehaviour { Transform target; //the enemy's target public float moveSpeed= 3; //move speed public float rotationSpeed= 3; //speed of turning public float attackRange= 3; // distance within which to attack public float chaseRange= 10; // distance within which to start chasing public float giveUpRange= 20; // distance beyond which AI gives up public float attackRepeatTime = 1.5f; // delay between attacks when within range public GameObject anim; public float maximumHitPoints= 5.0f; public float hitPoints= 5.0f; public GameObject Zombie_New; //public Transform AudioClip attack; private bool chasing= false; private float attackTime; bool checkRay = false; public string idleAnim = "idle"; public string walkAnim = "walk"; public string attackAnim = "attack"; int dontComeCloserRange = 2; private Transform myTransform; //current transform data of this enemy void Awake (){ myTransform = transform; //cache transform data for easy access/preformance ///zombie_New.anim.GetComponent.<Animation>().wrapMode = WrapMode.Loop; Zombie_New.GetComponent<Animation> (). wrapMode = WrapMode.Loop; Zombie_New.GetComponent<Animation> ().wrapMode = WrapMode.Once; //anim.GetComponent.<Animation>()[attackAnim].wrapMode = WrapMode.Once; Zombie_New.GetComponent<Animation> ()[attackAnim].layer = 2; //anim.GetComponent.<Animation>()[attackAnim].layer = 2; //anim.GetComponent.<Animation>().Stop(); Zombie_New.GetComponent<Animation> ().Stop(); } void Start (){ target = GameObject.FindWithTag("Player").transform; } void Update (){ // check distance to target every frame: float distance = (target.position - myTransform.position).magnitude; if (distance < dontComeCloserRange){ moveSpeed = 0; //anim.GetComponent.<Animation>()[idleAnim]; Zombie_New.GetComponent<Animation> ().Play(idleAnim); //anim.GetComponent.<Animation>().CrossFade(idleAnim); Zombie_New.GetComponent<Animation> ().CrossFade(idleAnim); }else{ moveSpeed = Random.Range(2, 3); //anim.GetComponent.<Animation>().CrossFade(walkAnim); Zombie_New.GetComponent<Animation> ().CrossFade(walkAnim); } if (chasing) { //move towards the player myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime; //rotate to look at the player myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); transform.eulerAngles = new Vector3(0.0f, transform.eulerAngles.y, 0.0f); // give up, if too far away from target: if (distance > giveUpRange) { chasing = false; } // attack, if close enough, and if time is OK: if (distance < attackRange && Time.time > attackTime) { //anim.GetComponent.<Animation>()[attackAnim].speed = 4.0f; Zombie_New.GetComponent<Animation> ()[attackAnim].speed = 1.0f; //anim.GetComponent.<Animation>().CrossFade(attackAnim); Zombie_New.GetComponent<Animation> ().CrossFade(attackAnim); target.SendMessage( "ApplyDamage", maximumHitPoints); attackTime = Time.time + attackRepeatTime; //GetComponent.<AudioSource>().PlayOneShot(attack, 1.0f / GetComponent.<AudioSource>().volume); } } else { // not currently chasing. //anim.GetComponent.<Animation>() [idleAnim].speed = 4; Zombie_New.GetComponent<Animation> ()[idleAnim].speed = 4; //anim.GetComponent.<Animation>().CrossFade(idleAnim); Zombie_New.GetComponent<Animation> ().CrossFade(idleAnim); // start chasing if target comes close enough if (distance < chaseRange) { chasing = true; } } } void OnDrawGizmosSelected (){ Gizmos.color = Color.yellow; Gizmos.DrawWireSphere (transform.position, attackRange); Gizmos.color = Color.red; Gizmos.DrawWireSphere (transform.position, chaseRange); } } NewZombieAI.cs
  2. free unity project is provided by armedunity name is Au Fpskit 1.5 I want to know how to add enemy to that project please help guys
×
×
  • Create New...