rj-action-library/Runtime/Actions/Node3D/CopyPositionXZ.cs

48 lines
822 B
C#
Raw Normal View History

2025-11-28 14:24:23 +00:00
using Godot;
namespace Rokojori
{
[GlobalClass, Tool ]
public partial class CopyPositionXZ : Action
{
[Export]
public Node3D source;
[Export]
public Node3D target;
[Export]
public Vector3 offset = Vector3.Zero;
[Export]
public bool global = true;
protected override void _OnTrigger()
{
if ( source == null || target == null )
{
return;
}
if ( global )
{
var y = target.GlobalPosition.Y;
var position = source.GlobalPosition + offset;
position.Y = y;
target.GlobalPosition = position;
}
else
{
var y = target.Position.Y;
var position = source.Position + offset;
position.Y = y;
target.Position = position;
}
}
}
}