Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
4
Question by GetColor · Nov 13, 2012 at 03:44 AM · iosjoystick

Using the standard virtual joysticks in c#

Forgive me if I'm asking a question that's been answered a million times, but I really can't find what I'm looking for. I am using the virtual joysticks in the Unity standard assets (mobile) package. I drag and dropped the single stick into my scene, I also dragged two touch pads onto my game for what I'll need them for. I test my game, and yay! the joysticks move around with my thumb just like I'd expect. Perfect, now I just have to find a way to see the value of that joystick to move my character with... Then I run into issues.

I can't seem to figure out how to find the values of the virtual stick. I found a few different ways on other forum questions, with people finding they didn't work and then people eventually offered up 3rd party virtual joysticks... but I just want to get the Unity one to work.

Now, I code in c#, could that possibly be an issue? I tried creating a public "Joystick" variable and then just dragging and dropping the joystick in the scene into it... but Joystick wasn't a variable type, and thus it wouldn't let me. I went into the player settings and changed the horizontal axis that moves my character to get movement from all joysticks, with no luck either.

If someone does know know how to find the values, could you also explain how to find the values of the touch pads so I don't run into this issue in the future when working on those?

Any help is greatly appreciated! Thanks!

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

3 Replies

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

Answer by GetColor · Nov 14, 2012 at 06:25 AM

Alright! I solved my problem.

First off, I didn't realize the unity virtual sticks were javascript. So after banging my head against google long enough, I found out that you can reference java objects as long as the script is compiled first... which is easy enough because the folder "standard assets" is compiled first - but "standard assets (mobile)" is NOT compiled first. So basically all I had to do was drag the "joystick" javascript from the standard assets mobile folder into the standard assets folder. SIMPLE! :D

Then it recognized the variable type "Joystick" in my c# script. So I created a public joystick variable, dragged and dropped my joystick prefab from my scene into it, and then was able to control my character using my joystickvariable.position.x in place of my normal input.getaxis("axis name") code.

Anyways! I've seen people have this same issue without a real conclusion, so I hope me posting this will help out another noob coder :P

Comment
Add comment · Show 5 · 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 Captain_Dando · Dec 21, 2012 at 11:48 AM 2
Share

Thanks, you've helped me finally get $$anonymous$$e to work. it's very considerate of you to put your solution here

avatar image SEVO · May 28, 2013 at 02:01 PM 0
Share

Awesome work there, I too was getting nowhere fast with C# and the pre-fab joystick. Without you I would also be banging my head against Google.

avatar image JoeyGameDev · May 30, 2013 at 03:45 AM 0
Share

Thank you so much! I spent half the night trying to figure this out!!

avatar image dogprez · Jan 17, 2014 at 06:54 PM 0
Share

here is why: http://docs.unity3d.com/Documentation/$$anonymous$$anual/ScriptCompileOrderFolders.html

avatar image GizmoMKD · Dec 08, 2014 at 06:34 PM 0
Share

alter long google search finally I found this one.. thanks.

avatar image
0

Answer by dogprez · Jan 17, 2014 at 07:45 PM

Just like Sussy said, but here is the reason why: http://docs.unity3d.com/Documentation/Manual/ScriptCompileOrderFolders.html

Comment
Add comment · 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
0

Answer by $$anonymous$$ · Feb 22, 2014 at 08:32 AM

You can always rename the Standard Assets(mobile) folder to Standard Assets and just copy all mobile assets under a subfolder named mobile.The important part is for the root folder to be called Standard Assets to be considered first pass material and avoid messing with the script compile order.

Be sure to do it in Unity so links to scripts on the prefabs are managed automatically and you don't have to fix them yourselves.

Comment
Add comment · 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

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

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to make Lerpz Sidescroller work with iPhone Joystick? 1 Answer

MobileJoyStick not working on Unity Remote for iOS. 0 Answers

FPS Camera rotates on Z when using a joystick 0 Answers

Constrain touch joystick around a point 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