- Home /
character touch/tap-to-move not interact with camera drag movement
Hi pros.. I am total newbie here I tried to make my character move to touch in android by using touchphase.ended.. i able to move him but i planned to do something like, if once i move my finger after i touched the screen, the touch phase.ended will be not executed. so my character just move on single tap but not on dragging
this is important for me so that the character not move while drag camera movement
here is my code
using UnityEngine; using System.Collections;
public class GoToMouse : MonoBehaviour {
public float speed = 1.5f;
private Vector2 target;
void Start ()
{
target = transform.position;
}
void Update ()
{
Touch[] touches = Input.touches;
if (touches.Length == 1)
{
if (touches[0].phase == TouchPhase.Ended)
{
target = Camera.main.ScreenToWorldPoint (Input.mousePosition);
}
if (touches[0].phase == TouchPhase.Moved)
{
// TouchPhase.Ended will be not working/no action to be taken once TouchPhase.Moved.. help plss
}
}
transform.position = Vector2.MoveTowards (transform.position, target, speed * Time.deltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
Drag Object, same speed as mouse/touch 3 Answers
Move Camera Over Terrain Using Touch Input 2 Answers
Dragging Camera based on Touch 0 Answers
Tap to Move Drag to Look Null Reference 1 Answer
Camera not moving 'smoothly' on drag. 2 Answers