|
I've attached an image to help explain show what I'm doing. So far I have the ray being cast when the user "fires" and whatnot. I have it then instantiate a prefab in the direction of the cast ray. How do i get the prefab to move in the direction of the ray/shot but with the ability to control its speed? Below are the snippets of code I'm using to generate my bullets. Aside from this my other question is how do I make the bullet know whether it hits and object or not? I'm excited to hear back and get this going. Thank you guys for all your help so far. This javascript is on my camera. This javascript is on my prefab(bullet).
(comments are locked)
|
|
Simple example given in FPS Tutorial may answer your question. you can find the answers in the code snippet below. // Did we hit anything? if (Physics.Raycast (transform.position, direction, hit, range)) { // Apply a force to the rigidbody we hit if (hit.rigidbody) hit.rigidbody.AddForceAtPosition(force * direction, hit.point);
Jul 25 '12 at 04:51 AM
BeHappy
(comments are locked)
|

