Player/PhysicsPusher.cs
public sealed class PhysicsPusher : Component
{
[Property] public float Radius { get; set; } = 32;
public float PushPower => 1500f;
bool CompatibleTags( Component component )
{
return !component.Tags.Has( "pickup" );
}
protected override void OnUpdate()
{
var box = BBox.FromPositionAndSize( GameObject.Transform.Position, Radius );
var objects = Scene.FindInPhysics( box );
foreach ( var obj in objects.Select( x => x.Components.Get<Rigidbody>() ).Where( x => x is not null ).Where( x => CompatibleTags( x ) ) )
{
var direction = (obj.Transform.Position - GameObject.Transform.Position);
obj.ApplyForce( direction * PushPower );
}
}
}