- Home /
Question by
RuiFerreira · Feb 26, 2014 at 08:06 AM ·
javascriptbuttonjump
Jump on button press. [JavaScript]
Hey guys, how can i connect the var for it to work in line 15 of the script. I have a button on screen that says "Jump" and when you click I want a certain object to jump. Plus is that the right way to write a button jump script " rigidbody.AddForce(Vector3)"? Here's what I got so far. Thanks. p.s. i'm new to coding.
var obje : Transform;
function OnMouseEnter()
{
renderer.material.color = Color.green;
}
function OnMouseExit()
{
renderer.material.color = Color.white;
}
function OnMouseUp()
{
(obje)rigidbody.AddForce(Vector3)
}
Comment
Best Answer
Answer by GenuiTix · Feb 26, 2014 at 08:29 AM
Below commentary for jumping instruction is considered to use with rigidbody attached to your object.
function OnGUI (){
if (GUI.Button(Rect(x,y, length, width), "Jump")){
//Your code for jumping
//e.g. object.rigidboady.AddForce(Vector3.up * jumphight);
}
}
Your answer
Follow this Question
Related Questions
Creates object under itself, not parent 0 Answers
How do I make the buttons work on this GUI? 2 Answers
Assign a hotkey to a GUI button? 3 Answers
Button wont work when character is on ground 0 Answers
2D Character Jumps only 1 time 2 Answers