Is there a way to check if an object is grabbed by a physics handle?

I mean from a different blueprint, like let’s say character A is holding an object using physicshandle, is there a way for the code for character B to check if that object is being held by another physics handle or not?

For instance to make it impossible for two characters to hold the same object, or implement special behavior when two characters try to hold the same object?

you can use an interface, player A grabs an item, sets a bool by interface bIsHeld? player B can check the bool by the same interface

i’m not sure i follow, where is the bool set and how do different players fetch it?

the bool will be on the object grabbed.

interfaces allow us to call functions on any object that implements it.

so on pickup call the ‘SetIsHeld’ function by interface (you should have a Ref to the object if you’ve picked it up)

and then whenever a play tries to pick up an object call ‘CheckIsHeld’ function by interface

Ok, I get the concept,but I need this to work for a large range of objects, most of which don’t have a dedicated bp (just physics enabled meshes)

Implementing it on a per object basis could work but i don’t like the idea of implementing a bp for a bunch of objects just to tack one bool on them.

you could try Tags, im not sure off the top of my head if it needs to be an ActorBP.

if physics is only enabled when you grab it you can use IsSimulatingPhysics?

otherwise its not too hard to convert to BP just use a parent actor and in the children you just override the mesh

2 Likes

Last time I checked, the grabbed component wouldn’t know it was being grabbed. There’s no owner, no attachment, no instigator. However, you can set the Instigator manually - it’d have to be a Pawn, or set the Owner - any actor. Querying the Grabbed Component would then either return one of the above, or none if it’s not being held - providing you remember to nullify it on release, ofc.


Regarding tags: Static Meshes in the scene are already converted to actors - Static Mesh Actors to be exact. They come with an inherited Static Mesh Component. You can either tag that actor or its component. The tag list is fully dynamic.

Both methods should work without adding anything to the already existing entities.

2 Likes

Setting the owner seems like the perfect solution. The instigator won’t always be the owner in my case but that’s a good idea as well. Thanks!

Edit: I could have sworn I tested setting the owner of a static mesh actor today and it worked :thinking: but it doesn’t seem to be anymore. I guess i’ll have to try the tag approach.

since youre talking about multiplayer make sure you set the owner on the server

oh it’s not actually multiplayer in that sense. Only one player but he can switch between pawns and stuff.

I made a separate thread about this Does 'Set Owner' not work for Static Mesh Actors?

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