Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Raycast Pause Between Hits?

$
0
0
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); }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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