Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy walking above ground

$
0
0
Hi there! So my problem is that my enemy which is a zombie is walking above the ground when he wants to chase me.. here's my script for my enemy : var target : Transform; //the enemy's target var moveSpeed = 3; //move speed var rotationSpeed = 3; //speed of turning var myTransform : Transform; //current transform data of this enemy var isNotDead : boolean = true; var health : float = 100; function Awake() { myTransform = transform; //cache transform data for easy access/preformance } function Start() { target = GameObject.FindWithTag("Player").transform; //target the player } function Update () { if(health < 1){ isNotDead = false; animation.Play("die"); Destroy(gameObject, 1); } if(isNotDead){ //rotate to look at the player myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); var distance = Vector3.Distance(target.position, myTransform.position); if (distance < 3.0f) { animation.Play("attack1"); } else{ //move towards the player myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime; animation.Play("walk1"); } } } function ApplyDamage(dmg : float){ health -= dmg; audio.Play(); } anyway there are bunch of animations set up to this enemy and i have freezed the x,y,z in the Rigidbody ( freeze position ) Please help me ASAP! Thanksss

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>