Answer the question
In order to leave comments, you need to log in
C# How to remap a key click (left-right) to a touch on an object on the screen (for example, a left-right arrow)?
Script for the character, namely - the part related to movement
public class MovePlayer : Unit
private void Update()
{
if (Input.GetButton("Horizontal")) Run();
}
private void Run() //
{
Vector3 direction = transform.right * Input.GetAxis("Horizontal");
transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, speed * Time.deltaTime);
sprite.flipX = direction.x < 0f;
}
public class Touch : MonoBehaviour
{
void Start()
{
}
void OnMouseDown()
{
Debug.Log("OnMouseDown");
}
}
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