- Home /
Pinball Joystick
Hello, I'm trying to build a pinball game. I'm following the script joystick.js present in the standard assets (mobile) where you create two virtual joystick. Unfortunately I can not implement motion with a joystick and other movement per second. I wish that when I press the joystick right to stand up and lower the right controller, but if I press the left rises the controller left.
This is the scripts that I need to simulate the movement of the controllers.
var commandKey : String;
var restPosition : float = 0F;
var pressedPosition : float = -1;
var configurableJoint : ConfigurableJoint;
private var isGoingToPressedPosition : boolean = false;
function IsGoingToPressedPosition : boolean {
return isGoingToPressedPosition;
}
function GoToPressedPosition(){
configurableJoint.targetRotation.z = pressedPosition;
isGoingToPressedPosition = true;
}
function GoToRestPosition(){
configurableJoint.targetRotation.z = restPosition;
isGoingToPressedPosition = false;
}
}
function FixedUpdate(){
if(Input.GetKey(commandKey)
|| (commandKey == "q" && Input.GetKey(KeyCode.LeftArrow))
|| (commandKey == "q" && Input.GetKey(KeyCode.RightArrow))) {
GoToPressedPosition();
}
else {
GoToRestPosition();
}
}
Can anyone help me figure out how to integrate my code in the script joystick.js (found in standard assets (Mobile)), making sure that it works? thanks for the help
Your answer
![](https://koobas.hobune.stream/wayback/20220612145104im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Iphone joystick where player touches 0 Answers
Joystick / Button 3 Answers
Joystick C# change touch zone? 0 Answers
ITouch multi touch with joystick problem 0 Answers
Car MultiTouch Controls 0 Answers