using Godot; using System; public partial class camera : Camera2D { [Export] public Vector2 OffsetAmount = new Vector2(50, 70); [Export] public float SmoothingSpeed = 0.05f; // Called when the node enters the scene tree for the first time. public CharacterBody2D Player; public override void _Ready() { Player = GetParent(); } public override void _Process(double delta) { Vector2 playerPos = Player.GlobalPosition; Vector2 playerV = Player.Velocity; Vector2 direction = playerV.Normalized(); Vector2 cameraTargetPos = playerPos + OffsetAmount * direction; GlobalPosition = GlobalPosition.Lerp(cameraTargetPos, SmoothingSpeed); } }