test/Player/ClickToDestroy.cs
public sealed class ClickToDestroy : Component
{
[Property, InputAction]
public string InputAct { get; set; } = "Attack1";
[Property]
public float Radius { get; set; } = 40f;
protected override void OnUpdate()
{
if ( Input.Pressed( InputAct ) )
{
var camRot = Scene.Camera.WorldRotation;
var tr = Scene.Trace.Ray( new Ray( Scene.Camera.WorldPosition, camRot.Forward ), 1000f )
.IgnoreGameObjectHierarchy( GameObject.Root )
.Run();
if ( tr.Hit )
{
using ( Scene.Push() )
{
var go = new GameObject( "Remover" );
go.WorldPosition = tr.HitPosition;
var comp = go.AddComponent<GaussianSplatVolume>();
comp.Mode = SplatVolumeMode.Subtract;
comp.Shape = SplatVolumeShape.Sphere;
comp.Radius = Radius;
comp.Intensity = 1f;
comp.Falloff = 0f;
}
}
}
}
}