x


2d side scroller projectile/firing weapon script help needed.

Hey guys, I'm pretty new to Unity and such but I've figured out quite a bit thus far. However I still need some help with a gun script/projectile firing script.

Here's what I'm at so far. I've been doing lots of work to animate this character and he fires his weapon from his arm, however, I was a bit clueless on how to start the script for a projectile or anything.

I DID make a prefab for a projectile, so I know that I need to make that, but this one script I found while looking for help(I was hoping it'd just make my life easier and I'd analyze it later, haha) merely made them appear and not go away, but not fire, and especially not fire from his arm.

I then deduced that I'd need to make the blaster on his arm a weapon which would indicate to fire said projectile and then how fast and what direction.

However I'm still clueless code-wise on a lot of this stuff.

I'm not asking for a complete code, but snippets and DETAILED explanations to help me out are extremely appreciated.

To clarify/reiterate: I just want his arm blaster to fire a projectile forward(it's side-scrolling, remember) from where he points his blaster.

And to remind: Projectile is already a prefab, so if your step-by-step help includes that, don't worry, I got that much already.

more ▼

asked May 16 '11 at 02:39 AM

user-12801 (google) gravatar image

user-12801 (google)
13 2 2 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Check out this question: http://answers.unity3d.com/questions/10957/shooting-a-projectile-forward-in-3d-space.html

It comes down to a process like this:

  1. Instantiate a projectile from a spawn point of some sort
  2. apply the appropriate force (or otherwise place it in motion)
more ▼

answered Jun 02 '11 at 11:31 PM

Chris D gravatar image

Chris D
2.5k 5 7 25

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5051
x1032
x445
x251
x53

asked: May 16 '11 at 02:39 AM

Seen: 2271 times

Last Updated: Jun 02 '11 at 11:33 PM