Supermarket Simulator Shelf Mechanics

Hello everyone,
I’ve been trying Supermarket Simulator and thought of trying to implement shelf mechanics in unreal engine 5, but I can’t figure out the best way to not lose too much performance and idealize a shelf that can receive different products by aligning them all differently based on their size. Any ideas? With sockets for each product it would become hundreds of sockets for a single shelf and it would be hard to figure it out.
Thank you all very much

How about this:

Would that work for you?

1 Like

This is a good solution, it would definitely work well for creating preset shelves, but I wouldn’t know how to do it if I wanted to put one object at a time, as it adds rows and columns and not individual objects.

If you want to place items individually (it’s unclear to me how the final product is suppose to work), box trace with orientation (+ optional snap to grid to align) to find out whether an item fits the space.

I am imagining being a store clerk and must place items of various dimentions on the same shelving unit. And it better be neat, or else!

Can you tell me please how have you done that X and Y variables all in one?

Let me explain:

1 - I take an object(example: bread) and put it in the shelf.
2 - I take a second object(example: can) and I want it not to be possible to put it in the same shelf but in a different one
3 - I take the bread again and put it next to the other and so on until the space is used up
I want for the same shelf I can put all the objects I create, but in one shelf the objects must all be of the same type.

You can see the variable type on the left of the screenshot - IntPoint. You may use 2 ints instead, it does not matter.

This part seems straighforward. Have a look at enumerators, flag item types. When plopping items down, query the shelf for the item type it accepts. If shelf has no type, place an item → have the shelf inherits item type.

I tried but i don’t have that layout. I must to use break to see the 2 variables. idk why

Right click any struct pin to split it.

Sorry, but in English the same word “shelf” is used to mean several things. I have a shelf and in the shelf there are compartments. i want the compartments to accept all kinds of products but if i put one in i have to keep using that to fill it all. However, I want to make sure that for each product I have a different grid that is adapted to the type of product and its size so that smaller products are not too detached in case I use the same grid for everything. To understand better what I mean there are many gameplays of “Supermakert Simulator” where you see these mechanics.

I’d rather not spend time looking for the right video, thanks. My advice is, learn about and become comfortable with the bits mentioned above, namely:

• line / box tracing
• collision
• enumeration
• blueprint comms
• basics of vector math (at least the engine’s implementation since you may be already familiar with it)

I believe the grid size should be dynamic here, I’d avoid hard-coding values (or sockets, sounds like a bad idea) - calculate it procedurally using mesh extents, the original example already has a basic implementation of it. If you need to account for specific rotation when stacking shelves / filling compartments, definitely explore box tracing with orientation - it will be handy here.

1 Like

Yes but using the grid there is a problem. I can’t add and remove all the elements one by one unless I could make only some elements in the grid not visible. Can this be done? Or should I consider other possibilities?

You can add / remove any element from the grid. Please do look into tracing.

Sorry again, where should I look? I’ve been looking for documentation/guide on 2d grid macro but can’t find anything.

There is no documentation, this is just a single helper macro node that can generate a grid, a shortcut to avoid doing vector math yourself. You eventually mentioned there will be no need for a pre-populated grid and we instead place items one by one. In which case you do not need the macro. The bit of the script that returns mesh radius will be handy when generating non-overlapping item positions, though.

Look for tracing tutorials, find out how mesh extent works. How to place objects on surfaces, normals, vector snapping and the other bullet points mentioned above.

Without the fundamentals, you’ll be banging your head against a shelf wall.

Circling back to this one more time. Assuming you know the elementary stuff like events, functions, arrays, framework classes, referencing and basic communication… Even then, avoid making an entire game in one go. Break it down into smaller pieces and learn that piece.

  • can you make a character navigate around? Enhanced Input + Control Rotation
  • can you pick up and carry stuff on the ground? Line Tracing + Attach / Detach Actors & Component
  • do you need physics when holding items? Physics Handle
  • can you interact with various actors? Interface
  • can you spawn new items? Spawn Actor from Class + Referencing
  • can you place items down? Line Trace + Normal
  • can you place items down with an animation? Timelines and / or Splines
  • can you place items down without them overlapping? Extents + Vector Math & Rotators + Box Tracing
  • can you snap to grid? Combination of above stuff + Vector Snapping + more Vector Math
  • do you want it to be somewhat performant and simplify spawning? Instanced Static Meshes
  • are you getting overwhelmed with classes? Inheritance
  • too many variables to handle all of a sudden? Structs
  • too much data to hard-code? Data Tables

I’d advise against the following but your mileage may vary:

  • do not make a main menu, you’re just prototyping / learning
  • do not start making a save game system
  • do not make a player inventory of any sort
  • do not overcomplicate the UI
  • do not fixate on optimisation
1 Like

did you ever figure this out as im trying to figure this out myself

1 Like