throwing an object using 'Add Force' or 'Impulse' after picking it up?

Hello, I’m quite new to this but I want to pick up an object then throw it.

I attached the object (that I want to pick up) from the level, to my character using ‘Attach Actor to Actor’, here’s the full code that picks and drops the object:

But I don’t just want to simply drop the object on the floor, I want to throw it, anyone know how I can do that? The main issue I’m facing is ‘Add Force’ node only allows ‘Primitive Component’ target, so since the object I just attached doesn’t actually belong to the character, I can’t use it. I have no idea what to do to solve it.

thank you for any replies

Hello, again, Str4w,

There’s a PROJECTILE COMPONENT that you can use (clicking “+ADD”). I haven’t used it in over a year, so its usage is rusty to me, however, it does take care of all the math associated with realistic projectile movement:

If you’re having issues, still, with throwing the same object that is in your character’s possession, you can DESTROY the actor, and SPAWN one in its place, and launch that instead.

using physics you do want add impulse not force but there is more you need to do,

the impulse needs to be added to the item root component.
when an item is attached you dont want collision on it as it will interfere with the owner. so you also need to enable collision and physics on the item before you add the impulse.

this should all be handled on the item, create a function called throw and pass in the impulse you wish you apply.

1 Like

Hello, wow thank you so much, your explanation is fantastic! :slight_smile: I now have it functioning, I just have one last question: I wanted to make the system usable on loads of different objects, in this snippet you can see I’m checking all overlapping actors seeing if they have a tag ‘pickup-able’, storing it in variable ‘Held Item’ then execute the code,

But in order for me to call the custom event I made in in the Object Blueprint (to enable the physics and add impulse) I need to cast to it directly. Which in the case of having multiple objects, wouldn’t be very efficient.

Do you know a better way I could do this?

Again thank you so much

Interfaces :slight_smile:

so create an interface called Interactables, and in that you can handle pickup, throw, drop etc

on your for loop call the interface, you dont even need to check if they have a tag, you can return a bool on the interface if you want to break the loop.

1 Like

Fantastic, I will set it up! thanks so much once again :blue_heart:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.