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

47 lines
719 B
C#
Raw Normal View History

2024-08-04 09:08:12 +00:00
using Godot;
namespace Rokojori
{
[GlobalClass, Tool ]
2025-01-08 18:46:17 +00:00
public partial class CopyPosition : Action
2024-08-04 09:08:12 +00:00
{
[Export]
public Node3D source;
[Export]
public Node3D target;
2025-11-26 14:23:59 +00:00
[Export]
public Vector3 offset = Vector3.Zero;
2025-06-23 11:16:01 +00:00
[Export]
public bool global = true;
2024-08-04 09:08:12 +00:00
2025-06-23 11:16:01 +00:00
// public override void _Process( double delta )
// {
// _OnTrigger();
// }
2024-08-04 09:08:12 +00:00
2025-01-08 18:46:17 +00:00
protected override void _OnTrigger()
2024-08-04 09:08:12 +00:00
{
if ( source == null || target == null )
{
return;
2025-11-26 14:23:59 +00:00
}
2024-08-04 09:08:12 +00:00
2025-06-23 11:16:01 +00:00
if ( global )
{
2025-11-26 14:23:59 +00:00
target.GlobalPosition = source.GlobalPosition + offset;
2025-06-23 11:16:01 +00:00
}
else
{
2025-11-26 14:23:59 +00:00
target.Position = source.Position + offset;
2025-06-23 11:16:01 +00:00
}
2024-08-04 09:08:12 +00:00
}
}
}