Player spawning and isometric in menu

This commit is contained in:
Marco 2025-06-18 15:16:43 +02:00
commit 1229613def
10 changed files with 286 additions and 43 deletions

View file

@ -23,14 +23,18 @@ public partial class CameraController3D : Camera3D
[Export] public NodePath TargetPath;
private Node3D _target;
private CameraTarget3D _target;
private Vector3 _currentPosition = Vector3.Zero;
private Vector3 _currentAimOffset = Vector3.Zero;
public override void _Ready()
{
Instance = this;
_target = GetNode<Node3D>(TargetPath);
RotationDegrees = new Vector3(-45f, 45f, 0f);
Projection = ProjectionType.Orthogonal;
_target = GetNode<CameraTarget3D>(TargetPath);
if (_target == null)
{
GD.PushError("Camera target not found.");
@ -40,13 +44,22 @@ public partial class CameraController3D : Camera3D
_currentPosition = GlobalPosition;
// Set fixed isometric angle once: -45° X tilt, 45° Y pan
RotationDegrees = new Vector3(-45f, 45f, 0f);
Projection = ProjectionType.Orthogonal;
}
public void RegisterTarget(CameraTarget3D target, bool jump = true)
{
// assert(not _active_target)
_target = target;
if (jump)
{
//_currentPosition = _activeTarget.GlobalPosition;
}
}
public override void _Process(double delta)
{
if (_target == null) return;
if (_target is null) return;
float dt = (float)delta;
Vector3 targetPos = _target.GlobalTransform.Origin;

View file

@ -0,0 +1,16 @@
using Godot;
namespace Cirno.Scripts.Misc;
public partial class CameraTarget3D : Marker3D
{
public override void _Ready()
{
// register with the controller
var res = GetTree().GetFirstNodeInGroup("camera_controllers");
if (res is CameraController3D cameraController)
{
cameraController.RegisterTarget(this);
}
}
}

View file

@ -0,0 +1 @@
uid://dnslcy71dgea