- Home /
Help Touch inputs
Heey Guys, I need help Soo Hears what, My problem is that my touch varriables arnt reachin g there full potential, Like on keyboard, Like say to go forward I press d and it goes quiet fast but when I transfer it to touch it like goes slow.. hears a copy of my code
var up = 0;
var down = 0;
var east = 10;
var west = 10;
var isFalling : boolean=true;
var Forwards : GUITexture;
var Backwards : GUITexture;
var Jump : GUITexture;
var Jumpvalue = 7;
function Awake() {
Forwards = GameObject.Find("Forward").guiTexture;
Backwards = GameObject.Find("Backwards").guiTexture;
Jump = GameObject.Find("Jump").guiTexture;
}
function Update()
{
for (var touch : Touch in Input.touches)
{
if (touch.phase == TouchPhase.Stationary && Forwards.HitTest (touch.position)) {
rigidbody.AddForce(Vector3.left * east);
}
if (touch.phase == TouchPhase.Stationary && Backwards.HitTest (touch.position)) {
rigidbody.AddForce(Vector3.right * west);
}
if (touch.phase == TouchPhase.Stationary && Jump.HitTest (touch.position) && !isFalling) {
rigidbody.velocity.y=(Jumpvalue);
}
isFalling=true;
}
//if (Input.GetKey("up"))
//{
//rigidbody.AddForce(Vector3.forward * up);
//}
//if (Input.GetKey("down"))
//{
//rigidbody.AddForce(0,0,1*down);
//}
if (Input.GetKey("d"))
{
rigidbody.AddForce(Vector3.left * east);
}
if (Input.GetKey("a"))
{
rigidbody.AddForce(Vector3.right * west);
}
if(Input.GetKeyDown("space") && !isFalling) {
rigidbody.velocity.y=(Jumpvalue);
}
isFalling=true;
}
function OnCollisionStay(CollisionInfo : Collision) {
//we are on somthing
isFalling=false;
}
help please,... Its set to release on the market very soon and I don't know whats worng hear
Comment
I would suspect that you are not getting a TouchPhase.Stationary every frame. Do you need that check at all as long as your have your HitTest() checks?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Ball in Pong dissapears after hitting paddle 0 Answers
Spray painting 0 Answers
Need Help making a simple game! 2 Answers
Melee Attack System 1 Answer