Question by
saadbitar98 · May 23, 2016 at 10:33 AM ·
keycode
how to add controller key to my game?
Hey Guys. in my simple game that i am making i have inputted the ball to jump by pressing space also i have a PC USB controller. So i need to make the ball jump using my USB controller. How can i do this , here is my code : #pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
private var isFalling = false;
function Update ()
{
//Handle ball rotation
var rotation : float= Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent.<Rigidbody>().AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode.Space) && isFalling== false)
{
GetComponent.<Rigidbody>().velocity.y = jumpHeight;
isFalling = true;
}
}
function OnCollisionStay ()
{
isFalling =false;
}
Comment
Your answer
Follow this Question
Related Questions
Turn on Prefab with Keycode issue 2 Answers
How to trigger game pause with clicking object instead of keycode? 0 Answers
How can I use on another scene the key bindings? 0 Answers
Xbox One Controller UI Buttons 0 Answers
Event.KeyCode not detecting mouse click 0 Answers