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
0
Question by Bizarri · Dec 21, 2013 at 12:35 PM · touchaxiswindowsjoystick

How to make virtual joystick (Windows Store)?

Hello, I need some help - I dont know how to make joystick. My idea is to make button (GUITexture) and programm it for change value of "Vertical axis" to 1 when press. I hope you understand it. I want just that button to imitate w/upper arrow. And I want four buttons for moving and one to jump, my problem is that I dont know how to programm this (my lang is C#).


More 'graphic' presentation of my idea:

  • BUTTON1 -> tap -> Vertical axis = 1;

  • BUTTON1 -> !tap -> Vertical axis = 0;

  • BUTTON2-> tap -> Vertical axis = -1;

  • BUTTON2-> !tap -> Vertical axis = 0;

Comment
Add comment · Show 2
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 Bizarri · Dec 23, 2013 at 05:09 PM 0
Share

? somebody ?

avatar image robertbu · Dec 23, 2013 at 05:16 PM 0
Share

To the best of my knowledge, you cannot simulate the hardware inputs, so you will need to write your own way to get input to the movement code. There are multiple different ways to implement your buttons. Probably the simplest is to use a separate GUITexture for each button and add a script to each with an On$$anonymous$$ouseDown() function.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Spinnernicholas · Dec 23, 2013 at 06:15 PM

Create Methods that are to accept the button commands:

 void OnButton1Click()
 {
 //Handle Button 1 Click
 }
 void OnButton2Click()
 {
 //Handle Button 2 Click
 }

Then on the guitexture, you can just send a message to the object with the script above:

 receivingObject.SendMessage("OnButton1Click"); 

And finally, in the same object as the receiver methods:

 bool button1Pressed = false;
 
 void Update()
 {
   if(button1Pressed)
   {
     //Vertical axis = 1;
     button1Pressed = false;
   }
   else
   {
     //Vertical axis = 0;
   }
 }
 
 void OnButton1Click()
 {
   button1Pressed = true;
 }
Comment
Add comment · Show 2 · 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 Bizarri · Dec 29, 2013 at 11:33 PM 0
Share

Im wondering how to write this: //Vertical axis = 0

avatar image Spinnernicholas · Dec 30, 2013 at 07:20 AM 0
Share

Just create a variable:

 //Declare it in class body
 int verticalAxis = 0;
 //Then you can set it like this
 verticalAxis = 1; //or = 0;

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

19 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

How to properly handle multitouch for virtual joystick? 0 Answers

Using Windows Embedded With Multi Touch 0 Answers

Custom Input manager problem 0 Answers

Steelseries 3gc controller key mappings 0 Answers

Get Axis from Mobile JoyStick 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