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

The enemy don´t lose health, but why???

$
0
0
#pragma strict var TheDammage : int = 50; var Distance : float; var MaxDistance : float = 1.5; var TheSystem : Transform; function Update () { if (Input.GetButtonDown("Fire1")) { animation.Play("Attack"); } // if (TheMace.animation.isPlaying == false) // { // TheMace.animation.CrossFade("Idle"); // } // // if (Input.GetKey (KeyCode.LeftShift)) // { // TheMace.animation.CrossFade("Sprint"); // } // // if (Input.GetKeyUp(KeyCode.LeftShift)) // { // TheMace.animation.CrossFade("Idle"); // } } function AttackDammage () { //Attack function var hit : RaycastHit; if (Physics.Raycast (TheSystem.transform.position, TheSystem.transform.TransformDirection(Vector3.forward), hit)) { Distance = hit.distance; if (Distance < MaxDistance) { hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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