Newbie question about grabbing/throwing

Hello everyone i am new in unreal and game engines in general.I want to make a local couch versus game with friends and i have some questions regarding some mechanics and what is the best way to implement them.The core mechanic of the game is to be able to grab 4 specific type items(players are octapi) and throw them whenever they want. I’ve searched tutorials about grabbing and throwing and i am trying to implement them.One of the problems i encountered is having to use event tick for the simple movement and then for grabbing/throwing.What’s the best way to go about that?Any help would be great!Thanks!

i would look into possibly using the projectile movement for the throwing for the sake of simplicity. as for the grabbing bit look into the attach to actor node.

Did you check this? I would use this kind of stuff for the grabing system, then if you want different bones to be grab, set a check to see which one is the closest.

I’ll try to do a quick BP to check how I’d do it

Hello and thanks for all the recommendations!I saw different kinds of videos like the above and i am trying to take something from them, to implement it.My bad for not clarifying a few things.The game’s camera is top down tilted camera that blends the distance between players and uses a spring arm to zoom in and out depending on the distance.So the question that comes to mind.Should i do it they line tracing way, but then add a camera to the player blueprint just to line trace with the forward vector?Also for simplicity’s sake i will use the x,y,b,a buttons of a controller to grab but also to throw if something is attached already on the hand. I guess with a bool to check if there is something on the hand already i can branch and execute the throw with the same button instead of grabbing.

After a few try, starting by a line trace because I was using Third person, in top down you should create a capsule trace and attach it to your character, when it collides with the ennemy, you can use a check to grab the closest bone, then set a bool, and branch the throw input with.

For the throw, I didn’t find something good, Launch character is the “best” I found

the throwing is where the projectile movement comes in. all you need to do is set the initial velocity then activate it. basically on pickup: attach to actor → set / align the rotations, on throw: detach from actor → set active true on the movement component.

Hey thanks again for the help!Didn’t have the time to implement it yesterday due to work.Capsule trace seem to be more fit in this case!So use capsule trace to pick up and then attach to a socket or to the actor?We are still kinda prototyping the whole thing and i wonder if attaching to the actor will make for example the object just float near the character?Because like i said the character might be able to have 4 items grabbed at the same time, for now i guess just having them move along with the character and then just throwing them is enough.As for the throw that seems pretty straightforward!

You want to attach 4 meshes at the same times? I don t know about colisions but it can be weird. I though you wanted to attach one bone of one character at time. For your case i would set different rotations for throwing and probably disable collision until they re launched.

Okok, well let us know if it works!

im not sure how your looking to implement the throwing or rather how to decide which item to throw but the actual getting 4 items attached is pretty easy if you have 4 sockets on the character. you will just need to be able to test if there is a unpopulated socket and attach the new item to the empty socket.

ok so i was trying to make an example of how this could work for multiple objects. my basic idea was to have a different socket for each arm/tentacle. i was also working with the thirdperson template.

so to start i added a socket to each hand and each foot and used numbers as the name (0,1,2,3). then for the sake of testing i made a box collision in front of the character to be able to get the pickup items.

for the actual script i began with a input event for picking up the items (Q). then i got the box collision and found all overlapping actors of the item pickup type (octopickup). i then did a for each si fir each one of the pickup items i did the following. i used a loop to go through an array to see if a index was populated by one of the pickups. if the index was populated i just moved on to the next one but if there was no pickup in that index then i assigned the current pickup to that index an broke out of the loop. this process gets repeated for all items. the item was also attached to one of the sockets at this point. the index of the array is the socket that it was attached to. also if all indexes are populated then the item from the for each loop isnt picked up.

the next thing to make was a way to detach the items from the character. i based this on each socket being assigned to a separate input, like socket 0 would be the 1 key, socket 1 the 2 key, etc. basically here i just got the array of attached items and got the index associated with the the socket/input. then i checked to see if it was a pickup via a cast. if it was a pickup then i detached it from the character, if it wasnt a pickup then i did nothing. once the item was detached i cleared the array index.

i got the attach and detach to work but couldnt get the actual launch to work via the projectile movement. it would work once but not if a item was picked up a second time.

Hey ThompsonN13 , thank you so much for taking the time!My implementation is… lets say not so elegant and has flaws.I am learning as i go so i ll see this a lot more :stuck_out_tongue: !I understand using sockets is the way to go but i didnt know how to set them up, i am currently checking them out!What i did is use four scene components and add them to my player blueprint, i call the grablocations.Then add 4 physics handles.For every button i have a separate handle and grab location(meaning i repeat the process posted on the pictures below 3 times more).Also i choose to do a radial trace but i understand its maybe an overkill in this case.In general it is still very messy and i am sorry for you are about to see bellow :stuck_out_tongue:

yea the pics are a bit low rez and hard to follow but the important question is does it work? i would imagine using scene components to set a location would work and using a impulse to throw objects is a solid way to do things too.

im not sure what you have coming off tick but i would be careful how much you drive off tick since it can be easy to create a situation where it slows your game down.

Did you already try to simply set a bool for half a second in the pickable object/actor to don’t allow to be picked up right after been thrown?

Sorry for the quality!It kinda works, meaning i can grab and throw the objects(telekinetically) but if let’s say i have one slot/arm empty and one of the other sockets has an object.The empty hand/slot will atempt to grab the other.It doesnt change hand or slot but is kinda weird.The ticks are to set the physics handle and grablocation transformation.Anyway in the next iteration i will use your approach much cleaner and to the point!Thanks for taking the time!

Yes i want the character(the octopus in this case) to have 4 sphere meshes max(the only things you will be able to pick up and throw).I thought as much for the disabling collision otherwise its going to get wild :p.If its not doable then i guess i ll have to rethink the whole thing.I know its hard for 4 objects at the same time

Nope thanks for mentioning it!Even if i tried replicating what you said , maybe because of the impulse i can’t grab it , but its an oversight and i should implement it!Because maybe the other players might be able to grab it possibly and i want the picked up item to damage the other player.

I didn’t know about the one use of the impulse movement, and if you use the forward vector of the player and launch it? it should be easier? I’m pretty sure it could look the same.
then you can do it how many times you want

EDIT: Launch is only for pawns, so if yours are not it won’t work, I’ve done it when I hit ennemies, they’re thrown back, the movement looks like in Zelda.

I wonder if Thompson could see this, he probably could give more help about the impulse

Throwing works just fine!I do indeed what you just said, using the forward vector with an impulse!Yeah i dont use launch at all, anyway i think this topic is more or less case closed!Thanks for your time!