Answer the question
In order to leave comments, you need to log in
How to set the movement of the player using swipes?
Hello everyone, I watched a video on how to make player movements using swipes and on the video the person doesn’t have exactly what I need, he uses the Vector3.MoveTowards method that moves the player a certain distance, but I need something to say, when swiping up an object moved continuously up, until the moment you make a swipe to the left, after that it stops moving up and starts moving towards the swipe, that is, to the left. How to do this, or what is the best method to do this? Many thanks in advance!
This is the code of the movement itself from the author of the video *
public float moveSpeed;
private Vector3 targetPosition;
private void Start()
{
targetPosition = transform.position;
}
public void Move(Vector3 moveDirection)
{
targetPosition += moveDirection;
}
private void FixedUpdate()
{
transform.position = Vector3.MoveTowards(transform.position, targetPosition, moveSpeed * Time.deltaTime);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question