Snapping objects during gameplay

I am making an interactive house, and I’m trying to find out how to make player to be able to place items from inventory to a particular “Slots” in the world.
For example, I have a kitchen shelf or a fridge and I want the player to be able to place objects there on certain places. For example I have let’s say 1 unit square on the shelf, where i can place 1 cabbage or 4 milk bottles, or two egg cartons, or 1 egg carton and two milk bottles, etc. And each should stick to the particular place on the shelf.

When I search for snapping all I find is how to use it while editing.
I thought that maybe I should use sockets if I understand correctly what they a made for, but still can’t find any good tutorial except for armor and weapons on character’s body.
Also it seems that in my case this sockets need to overlap and have ability to turn on and off other. As if Player already used the biggest socket smaller ones should be blocked from interaction.

Hi man,

You can do this in a lot of ways.
a lot depend on your inventory and drag and drop system,

I would make a Slot-Blueprint, something like a 4 cubes that offer collision .
So when i drop a milk bottle, i would raycast to see if i dropped on a cube of Slot-blueprint.

If something has been droped on it ,
check if the slots are empty, if yes , check if the type of object you want to drop have the size that fit, if yes, delete the item from the inventory.

In The blueprint you should make some variables to store the various slots and theyr location , so when an egg-carton is dropped, you should check if 2 slots are empy,
and if yes, add or set a static mesh component with the Egg Carton and place it correctly.
Dont forget to manage the slots availability and the “You didn dropped on the shelf” event XD

This node might be helpful if you don’t want to deal with sockets

image

Thank you guys, now I know where to move

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.