How to create a working trash can?

HELP ME, I need this for a recycling project: So I’m trying to create a recycling game where’s two types of trash, cans and paper. And there is a trash can for each. The main idea is that you have to put this item into the correct trash can but I’m failing every time into making the interactions work. I managed to make that you can only pickup 1 item at a time and that when you pick it up it adds points, but I want to make it so that when you press E near a trash can it + or - points if it’s the correct trash type.

break this down into the smallest steps that you can.

for example:

  • identify an item type
  • hold an item type
  • interact with an object
  • interaction can determine context
  • given an interaction context, decide which interaction code to run
  • run deposit trash item action
  • deposit trash item action can search for a specific item at a specific location and * check for specific id
  • if ID == a certain target, then complete the action, otherwise print an error message

So from a list like that it is easier to start thinking about what variables and functions you need. The first thing I think you should figure out is, what variable can I use to identify an item?

So the player is holding some trash item. How do we know this is true, and how can we determine what the trash item is?

What is your trash item? Is it a separate blueprint? Tell us more about how you’ve set things up, then it will be easier to frame a solution around that.

1 Like

i was just typing something similar, but much less eloquently put, you beat me good answer!

It’s a good idea but I already did that, but I tried different tutorials and the code doesn’t really come together, + the seperate blueprints are a mess since the context/reference from one another is pretty much broken. My main issue is the code itself, I cant find the correct way of putting it all together.

its too much effort to create a big example and there is a billion tutorials already showing how to do things like this.

If you want help, show what you’ve got and try to identify where it is failing. Then it will be easy to stitch it together so that it works.

1 Like

Alright, so i saw a tutorial on how to create this but it works by making an object fall down into the trash instead of an interaction. Do you know the game “Late Night Mop”? SO I am trying to do something like that, even if it’s without different types of trash.

So are the trash just open top bins?

if so simple, put a collison box at the bottom, and just detect the overlaps when the trash drops ontop, then detect what type of trash (easy enum to denote its type) and if it matches great if not do whatever has to be done. its very simple the trash just needs gravity and physics to be able to drop it

There’s a tutorial that makes it fall. But I want to just interact and count as a point. Otherwise the model has to be placed ontop and I cant interact with it.
I made a Haunted House Cleaning Simulator - YouTube (7:16). I dont understand how he manages to put all things together as a single interactable.

so you need an interact tutorial really for starters, one that creates a widget when close enough to press a key, or automatically if you want to. if its an interact button you want to press then like @BIGTIMEMASTER said go learn a tutorial on that as its a good learning curve. if its automatic when you reach the bin, then detect that on the begin overlap > check you have trash > check its correct trash > add or remove point > destroy the trash you carry

1 Like