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

32 lines
650 B
C#

using Godot;
namespace Rokojori
{
[GlobalClass]
public partial class PlaceRandomly : RJAction
{
[Export]
public Node3D start;
[Export]
public Node3D end;
[Export]
public Node3D target;
public override void _OnTrigger()
{
var lastNode = target.GetChild<Node3D>( target.GetChildCount() - 1 );
var rnd = LCG.Randomized();
var randomPosition = rnd.InCube() ;
randomPosition *= ( end.GlobalPosition - start.GlobalPosition );
randomPosition += start.GlobalPosition;
RJLog.Log( "Position", randomPosition );
lastNode.GlobalPosition = randomPosition;
}
}
}