- Home /
Other
Unlimitted run Game on mobile.
I'm working on mobile game it's a car moving automatically and the player just move it left and right by touch screen my question is how can I add or modify on my script below to make car just moving in three lanes as player touch like temple run and subway surfer .Also, when I tested my script I found problems in touch to move car left and right...how to say go or not to go right and left and how to determine 3 lanes also i need to know why my script not working perfectly...please help i'm lost in this give me an example don't let me like this I spent severa days in this without any benefit result.
public var position: Vector2;
var rotate : float = .2;
function Update () {
transform.Translate(Vector3.forward * Time.deltaTime*30);
if (Input.touchCount > 0 &&
Input.GetTouch(0).phase == TouchPhase.Moved)
{ var touchDeltaPosition:Vector2 = Input.GetTouch(0).deltaPosition;
transform.Rotate (0,touchDeltaPosition.y*rotate , 0);
touchDeltaPosition = position;}
if (Input.GetKey("escape")) {
Application.Quit();}}
Follow this Question
Related Questions
How to drag object along with dragging touch? 1 Answer
Help with iphone/android touch controls 2 Answers
Horizontal axis not working after animation 1 Answer
Touch movement not working 1 Answer