Can only place item on grid top side

main
copygirl 11 months ago
parent 16b52df702
commit f180a21946
  1. 8
      player/PickupController.cs

@ -87,8 +87,16 @@ public partial class PickupController : Node3D
if (!_player.IsLocal) return;
EnsureCurrentItemValid();
static bool CanPlaceAgainst(Grid grid, Vector3 normal)
{
normal = grid.GlobalBasis.Inverse() * normal;
return normal.IsEqualApprox(Vector3.Up);
}
if (HasItemsHeld) {
if ((RayToMouseCursor() is RayResult ray) && (ray.Collider is Grid grid)
// Make sure this is placed against the top of the grid.
&& CanPlaceAgainst(grid, ray.Normal)
// Ensure item is not being added to itself or nested items.
&& !((grid.GetParent() == CurrentItem) || grid.ContainsItem(CurrentItem))) {
var transform = CurrentItem.GlobalTransform with { Origin = ray.Position };

Loading…
Cancel
Save