- Home /
how to define this variable input directly from script (not from editor) ?
hello
excuse me , could i know how to define jumpTouchPad input (game object) directly from script (not from editor) ?
what changes should i apply in this script ?
if you look at speed var , i want to define jumptouchpad input like that
private var canJump = false;
var Speed:float=80;
var jumpTouchPad : Joystick;
function FixedUpdate () {
var touchPad = jumpTouchPad;
if ( !touchPad.IsFingerDown() )
canJump = true;
if ( canJump && touchPad.IsFingerDown() )
{
canJump = true;
rigidbody.AddForce(Vector3.right*(Speed*Time.deltaTime));
}
}
Thanks A lot
What is Joystick
? I can find no documentation relating to it anywhere.
Answer by EvilTak · Apr 20, 2014 at 05:20 PM
You can use:var jumpTouchPad = new Joystick(constructor_arguments_here);
The new operator is available in JavaScript also. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new
Whoops, ignore my previous post [now deleted], I didn't see that the poster was using a library that apparently defines a Joystick class. Commenting without thinking :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613143134im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Converting JS to C# Issue 2 Answers
GameObject.Find either can't be called or is in the wrong scope. 0 Answers
Where did my 'j' go? 0 Answers
how to make public float refer to another script 0 Answers
relate two variables 1 Answer