When the Mouse Button is spammed the raycast hits multiple times instead of waiting till the animation is done any ideas??
#pragma strict
var TheDamage = 200;
var Effect : Transform;
function Update () {
Hit();
}
function Hit() {
if (Input.GetMouseButtonDown(0))
{
var hit : RaycastHit;
var pos = Vector3(Screen.width / 2, Screen.height / 2, Camera.main.nearClipPlane);
var ray = Camera.main.ScreenPointToRay(pos);
animation.Play("Axe");
if (Physics.Raycast(ray, hit, 5))
{
yield WaitForSeconds(0.4);
var particalClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(Vector3.up, hit.normal));
Destroy (particalClone.gameObject, 0.5);
hit.transform.SendMessage("ApplyDammage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
yield WaitForSeconds(3);
}
↧