Picking up and throwing an object

I need to set up a system where I can pick up and throw objects, I’ve used the class blueprint described here as a starting point. My guess is I need to add a impulse to the object to the OnReleased and OnInputTouchEnd, I’ve attached an image of where I’m at, considering this is a class BP I’m not sure how to get the First person camera into this BP as a way of generating a vector for the impulse. Any suggestions would be greatly appreciated

Thanks

4562164a2470ae14c3906e630978f501ce59402a.jpeg

What blueprint is this screenshot of, the playercontroller? the pawn?

I assume this is the object-to-be-thrown BP, otherwise you wouldn’t have to ask:

if it’s singleplayer, simply do
get playercontroller(0) -> get controlled pawn -> get component (camera) -> get transform

if it is online multiplayer, you would first have to find out which playercontroller is yours (eg loop over all controllers and check if its local).

You could use a ‘get player character’ node, then cast to your character -> then as your character you’ll be able to access any of the character components (i.e. camera).

Ninja’d

Hello,
To loot item, you need to create a pick up item blueprint where you will set all infos related to your weapon. With infos, in your character, you can set your inventory and add it to your weapon list / system. If you equip it, you’ll need the reference of the mesh to attach. when equip, you use this mesh to attach to a socket of your character and when you throw it, you destroy the mesh (not the component but the mesh in it) and spawn a projectile like in the projectile system (blueprint and use in character blueprint) in first person project with the related mesh you are throwing .

Thanks a lot for the quick responses guys :slight_smile:

This is a class blueprint for the item that will be picked up and thrown in this instance a rock. What I’m trying to do in the example is to add a new pin to the sequence node connected to the onRelease node and get this to throw the rock with a random impulse (velocity that is) based on the direction the camera is facing. At the moment I’m at a beginner level with blueprints and still trying to get an understanding of the mechanics of BP, I understand the concept of casting but not quite sure how to get that info into the impulse vector of the add impulse node. I’m not quite sure if this is the correct way to do this due to my noobish scripting level :wink:

So, I’ve moved this on slightly and I’m a bit stumped - I’ve used the player camera manager -> get camera rotation -> get forward vector -> mult that vector by a large float and linked that to the impulse - no joy :frowning: - Any suggestions please

Any update here? I’m curious about forces and wondering if impulses are actually the right way apply motion to something.