How can I make a trap, that traps animals and then you can loot them?

Hi people. Is there a blueprint way to do this?
I am trying to make some kind of a survival rpg game. And I made a simple Ai for a walking around animals . How to make a trap that catches the animal and then you can loot it from it. Or may be smth else…just to put a trap that after some time generates an object inside like animal, instead of traping it. I know this is complex, but is there an way to do this with blueprints. And may be a trick or a way around , that is not so hard? I am still learning ,and I wanna make a game at the same time and I know this is kinda dumb for me.But may be this will be helpfull fot others.

A simple way to do it would be:

  • The player lays down a trap
  • The player leaves it there for a certain amount of time
  • When the player comes back, if the amount of time passed is greater than say, 15 mins, the trap will have spawned an item that the player can loot

I’m assuming you don’t actually see the animal get caught inside the cage, for that would be a little bit more complex, but if you want that, i can try to help you.

unless its a stylized game i probably wouldnt go with the spawn an animal in the cage unless you take measures to ensure that the player isnt in visual range when the animal is spawned, it just wouldnt look right. of course if stylized then you could have it appear in a puff of smoke or grow from a spec to full size or something like that. another thing to consider is the implementation in game like do you want the traps to sometimes fail or need to be rebaited? there us alot to consider but below i show two very basic examples, the first example is how you can trap animals that are just roaming out in the world, and the second shows the method of spawning the animal in a cage.

Picture 1: for the first example the basic idea is that when a animal walks onto the trap it activated and encloses the animal inside like if you built a cage around it. this idea works on alot of luck but could be built upon to lure animals in using bait or something similar. now on to how it works; on begin overlap the script checks to make sure its an animal and not the player or an npc then it sets a reference of the animal and activates a custom event “activate trap”. the activate trap event is where you would have the closing of the cage or spawning if you prefer or you could make some kind of ghostbuster hightech light toaster to trap the animal. in any case the animal is now trapped, you could also disable the animals movement at this point if you liked but i prefer the animal to move in the cage. the next part is the looting of the trap (this part is the same in both examples). for the looting i had a box collision around the trap so when the player is in range and presses the E key the script activates. the script then makes sure that there is a animal trapped which i did with a simple bool variable. the next step is to spawn the loot into the world or into the players inventory to do this i got the trapped animal reference and i got its loot table (in this case it is a actor class and can only drop one item, again this is where you can make things more complex), we then spawn the loot item at the traps location and destroy the trap and the animal it contains.

Picture 2: the second method is the spawn an animal in a cage after a set time, which is even simpler. here all you need to do is on begin play have a delay then a spawn actor of class and specify the actor class to spawn and have its location at the center of the trap. the looting is the same as above though it will need to be modified slightly to get the animal in the cage which i didnt do. this script can be modified to determine a random animal or to add a random amount to the interval time that it takes.

again this is just a very basic example but it should help get you started.

You are god. Thank you so much man. This means a lot to me, I will get into it immediately. I wll share my results when is done.