39 lines
800 B
C#
39 lines
800 B
C#
|
|
using Godot;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
|
||
|
|
namespace Rokojori;
|
||
|
|
|
||
|
|
[Tool]
|
||
|
|
[GlobalClass ]
|
||
|
|
public partial class SetPositionOnLineVFX:Action
|
||
|
|
{
|
||
|
|
[Export]
|
||
|
|
public Node3D target;
|
||
|
|
|
||
|
|
[Export]
|
||
|
|
public LineVFX lineVFX;
|
||
|
|
|
||
|
|
[Export( PropertyHint.Range, "0,1" ) ]
|
||
|
|
public float normalizedPosition = 0.5f;
|
||
|
|
|
||
|
|
[Export( PropertyHint.Range, "0,1" ) ]
|
||
|
|
public float normalizedRange = 0.5f;
|
||
|
|
|
||
|
|
protected override void _OnTrigger()
|
||
|
|
{
|
||
|
|
var random = GodotRandom.Get();
|
||
|
|
|
||
|
|
var min = normalizedPosition - normalizedRange;
|
||
|
|
var max = normalizedPosition + normalizedRange;
|
||
|
|
|
||
|
|
var t = random.Range( min, max );
|
||
|
|
t = MathX.Clamp01( t );
|
||
|
|
|
||
|
|
// this.LogInfo( t, normalizedPosition, normalizedRange, min, max );
|
||
|
|
|
||
|
|
var p = lineVFX.GetLerpedLinePositionAt( t );
|
||
|
|
|
||
|
|
target.GlobalPosition = p;
|
||
|
|
}
|
||
|
|
}
|