Download

Picking up and throwing objects and enemies (non-TPS/FPS)

Hi all! I have a question for anybody who might be able to help me!

If I wanted this little guy to be able to pick up that trash can object (and eventually an enemy character) and throw it at other objects/enemies, what would be the best way of going about it in BP?

pickingupandthrowing.PNG

I’ve looked through many tutorials that all seem to be based on FPS/TPS games with a line trace guided by the camera. As my character moves about independant of the camera (it’s a multiplayer Brawler game), I imagine a different method is required.

For enemies, they will be animated while grabbed and lifted off the ground but still move around with the player so the throw can be “aimed” at things. Throwable objects might hide health pickups, but if that’s too difficult/costly, I will reserve that for the smashables (like the arcade cabs in the back which can’t be picked up but can be destroyed).

Thanks in advance!

Hey I am working on a similar mechanic, did you find a workable solution in the end?

This is all theoretical as I’m not at m computer to test.

Possible solution is that You could create a socket eg on the characters hands and do the line trace from the characters hands instead of the camera .
Or the other way round . Do a line trace from the object you want to pick up and see if it hit the character instead.

Another way could be to use on trigger events.
Eg give the item you want to pick up a trigger box/sphere then Just use for example onBeginOverlap
Check that it Is the character overlapping you’re object . If so call the events to pick it up .

Or again the other way round . You could add the trigger box to the characters hands or even two trigger boxes . One for left hand one for right the. You could actually get the character to pick up an item either in he left hand or the right hand

Another more complicated method could be to create say a blueprint class of all the items that you want the player to be able to pick up. This could be done with a simple bool eg player can pick up item then tick for true untick for false.

Then let’s say you have an event like press left mouse to pick up the object . Inside this event it would work like this. On button clicked , find all actors of the class you made earlier. Then once you had the array you could check the distance between the player and the objects using a loop. Once you have found the item that is closest to the player you know tha this is the right item and also that the player can pick it up so then you just call the function or event and pick it up