- Home /
I Need Help With Mobile Touch Movement.
Hello Im Trying To Do a Game Where Player runs Away From Enemies On XY World My Problem Is That I Must Swipe Many Times To Move Player And i Want To Hold My Finger To Move
---------Script---------
#pragma strict
public var speed = 0.1F;
function Update() {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
// Get movement of the finger since last frame
var touchDeltaPosition = Input.GetTouch(0).deltaPosition;
// Move object across XY plane
transform.Translate(touchDeltaPosition.x * speed, touchDeltaPosition.y *speed,0);
}
}
Comment
Your answer
Follow this Question
Related Questions
Move horizontally on touch 0 Answers
Stop Moving When Not Touching Screen? 1 Answer
Moving character with touch buttons (Android) 1 Answer
touch position to world position 2D 2 Answers
Help with iphone/android touch controls 2 Answers