Mini Survival Shooter
Score: 0
GAME OVER
Final Score: 0
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed = 5f;
public float rotationSpeed = 10f;
void Update()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(x, 0, z);
if (movement.magnitude > 0.1f)
{
transform.Translate(
movement.normalized * speed * Time.deltaTime,
Space.World
);
Quaternion targetRotation =
Quaternion.LookRotation(movement);
transform.rotation = Quaternion.Slerp(
transform.rotation,
targetRotation,
rotationSpeed * Time.deltaTime
);
}
}
}