rj-action-library-godot-dev.../Scenes/Main/CameraRotation.cs

43 lines
706 B
C#

using Godot;
namespace Rokojori
{
[GlobalClass]
public partial class CameraRotation : Node
{
[Export]
public Node3D camera;
[Export]
public Node3D target;
[Export]
public float yaw;
[Export]
public float yawSpeed;
[Export]
public float pitch;
[Export]
public float distance;
public override void _Process( double delta )
{
if ( camera == null )
{
return;
}
yaw += (float) delta * yawSpeed;
yaw = MathX.Repeat( yaw, 360 );
camera.GlobalRotationDegrees = new Vector3( pitch, yaw, 0 );
camera.GlobalPosition = target.Position + camera.GlobalBasis.Z * distance;
}
}
}