Quantcast
Channel: Latest Questions by ryno9788
Viewing all articles
Browse latest Browse all 91

bow and arrow (load and fire)

$
0
0
I've been working on a bow for a fps shooter type deal. It works off the idea of getting mouse button down to pull the string back, and releasing the arrow with mouse button up (sorry it's really messy, just playing around with it). What it needs to do is, if release early drop or shoots very short, (maybe divide arrow speed by four) but how to I write this where I can get it to do this var arrowPrefab: Rigidbody; var ArrowSpeed = 100.0; var fireRate = 1.5; var nextFire = 0.0; var tIME = 0.0; var pulltime = 0.5; function Update () { tIME = Time.time; // pull back string if(Input.GetMouseButtonDown(0)&& Time.time > nextFire) { nextFire = Time.time + fireRate; animation.Play("PULLBACK"); } // fire arrow if(Input.GetMouseButtonUp(0)&& Time.time >= nextFire) { nextFire = Time.time + pulltime; animation.Play("FIRE"); var arrow : Rigidbody = Instantiate(arrowPrefab, GameObject.Find("FIREPOINT").transform.position, transform.rotation); Physics.IgnoreCollision(arrowPrefab.collider, transform.root.collider); arrow.rigidbody.AddForce(transform.forward * ArrowSpeed); }

Viewing all articles
Browse latest Browse all 91

Trending Articles



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