|
Hi! I am developing a 3d shooter and i was trying to shoot my enemy using rigidbody and then addForce. It all works great when i use the mouse but i wanted to use small taps to shoot bullets. I am using the following code to catch the touch input: My goal is to shoot the area that i am touching (without moving the cam) // touch,tap code float point; //shooting code Transform crate = Instantiate(cratePrefab, transform.position, Quaternion.identity) as Transform; crate.rigidbody.AddForce(transform.forward * 5000); How can i use the "ray" with the function i have to shoot bullets?
(comments are locked)
|
|
I agree with syclamoth about caching the player object. That aside... I don't see why you are using a Plane here. This looks more complicated than it has to be. Is this a 3rd person view or a 1st person view? 1st person! I followed a lead by another user -> http://unity3d.qatohost.com/questions/222121/raycast-from-player-to-touch-point.html
May 10 '12 at 03:13 PM
oziriz
(comments are locked)
|

Just in general, you should cache the player gameObject, instead of using GameObject.Find(name). Totally unrelated to the question, but it really bugs me every time I see someone using GameObject.Find for anything.
I started unity very recently...tanks anyway ;)