Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by RamenxNoodles · Apr 27, 2010 at 10:59 PM · joystickstickrightanalog

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by spinaljack · Apr 28, 2010 at 12:20 AM

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"));

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RamenxNoodles · Apr 28, 2010 at 01:54 AM 0
Share

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.

avatar image RamenxNoodles · May 04, 2010 at 09:59 PM 0
Share

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.

avatar image slippdouglas · Dec 08, 2014 at 08:12 AM 1
Share

-1 Your assumption that “the right stick is read as a second joystick” is incorrect.  Your solution would give you the main (left) stick of a 2nd controller connected to the system— great if you want a strange co-op mode, not so great if you want the game playable by one person.  Essentially here, Unity Technologies has mis-labeled “Controller” as “Joystick”.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to avoid sticky corners when moving around using joystick? 1 Answer

need the game to detect if the analog stick is at the opposite angle 2 Answers

[SOLVED] My XBOX controller right stick is always stuck at -1. 4 Answers

Analog stick control 1 Answer

MobileSingleStickControl Standalone 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges