I Top-Down spil, er det en fordel at flytte sin Player i alle fire pileretninger.
Opret et script til PlayerControl
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed;
public float rotationSpeed;
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector3 movementDirection = new Vector3(horizontalInput, 0, verticalInput);
movementDirection.Normalize();
transform.Translate(movementDirection * speed * Time.deltaTime, Space.World);
if (movementDirection != Vector3.zero)
{
Quaternion toRotation = Quaternion.LookRotation(movementDirection, Vector3.up);
transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotationSpeed * Time.deltaTime);
}
}
}