- Home /
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;
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.
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;
}
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
Follow this Question
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