- Home /
Question by
NopeStudiosz · Apr 20, 2014 at 05:38 PM ·
androiderrortouchjumpinghorizontal-slider
Jumping with touch input.
Hey. So I am using a script that allows a ball to rotate with the horizontal axis, and it has a jumping feature built in. (SPACE BAR) when I change it from
(Input.GetKeyDown(KeyCode.Space)
to
(Input.GetTouch(0)
I get the following compiler error.
UnityEngine.touch cannot be used in a boolean context
If you want the code for the jumping & moving thing to modify it, here it is. PS the spacebar works fine.
#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;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
if (Input.GetTouch(0) && isFalling == false)
{
rigidbody.velocity.y = jumpHeight;
}
isFalling = true;
}
function OnCollisionStay ()
{
isFalling = false;
}
Comment
Looking at the doc for GetTouch, seems like all the examples have something after it (dot-something)
Your answer
Follow this Question
Related Questions
foreach (Touch touch in Input.touches) not working 1 Answer
how do i use touch.Position 1 Answer
Problem with Input.touchCount == 1 1 Answer
Make sphere shoot to Touch.position error 1 Answer
How do i create mobile menus 1 Answer