x


Using Right Analog stick to fire weapon.

I making a top down space shooter similar to Astroids. I want to use my joystick's right analog stick to fire the players weapon similar to any game on PSN or XBLA of the same genre.

How would I acchomplish this in CSharp? Java is also fine if you don't know CSharp.

more ▼

asked Apr 27 '10 at 10:59 PM

RamenxNoodles gravatar image

RamenxNoodles
60 5 5 11

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

1 answer: sort voted first

In the input manager you can define extra controls such as the x and y axis of a second joystick (default is accept data from all joysticks so you might want to change that). Assuming the right stick is read as a second joystick, you can use the input from the right stick to aim your weapon similar to walking.

Use the look at function to turn your character to face the direction of the joystick e.g.

transform.LookAt(transform.position + Vector3.( Input.GetAxis ("Horizontal"),0, Input.GetAxis ("Vertical"));

more ▼

answered Apr 28 '10 at 12:20 AM

spinaljack gravatar image

spinaljack
9.1k 18 31 92

I see, I was wondering about that. Also there is still the need to for some code to make the player rotate depending on the direction the joystick goes. I think I can figure that out, but I would still appreciate any help.

Apr 28 '10 at 01:54 AM RamenxNoodles

For some reason Unity is not registering my joystick anymore so I will have to put this on hold. Thanks for the answer though it makes sense.

May 04 '10 at 09:59 PM RamenxNoodles
(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:

x223
x24
x24
x14

asked: Apr 27 '10 at 10:59 PM

Seen: 2312 times

Last Updated: Apr 27 '10 at 10:59 PM