BLOODJOE/Assets/Scripts/PlayerCamera.cs
2025-08-14 23:29:10 -05:00

23 lines
699 B
C#

using UnityEngine;
public class PlayerCamera : MonoBehaviour
{
public Vector3 offset;
public Transform player;
// Update is called once per frame
private void Update()
{
// Do nothing if the player isn't set
if (!player) return;
// Get the player's position, then zero out the vertical movement, we only want the camera to move on the x axis
var playerPos = player.position;
playerPos.y = 0;
// Set the camera to the player's position, plus the configured offset. Make sure the offset Z is negative so
// the camera isn't inside the 2D objects.
transform.position = playerPos + offset;
}
}