How to check if object is attached to socket?

Hello! I have a question regarding boolean checking. So I currently have a code piece that I can “grab” (attach to character socket) and “place” on a wall (attach to wall socket). But firstly, what I want is to put in a boolean to check if the character is “holding” the code piece, and only then be able to place it on the wall. And second, I also want to be able to check if all the wall sockets are “filled”, and then have an event happen. How should I go about this? I am very new to programming so please be patient if I ask silly questions.

Here’s my blueprints for you:




1 Like

Hello tamakerii,

The easiest way to do this would be to create two booleans. The first boolean would be on the character or player controller, whichever is being checked when picking up the object. This boolean could checked whenever you try to pick up an object. If it is false, it succeeds and the item is picked up. At this time, you would want to set it to true so that the boolean lets everything else know that the player is now holding an object.

The second boolean would be on the static mesh itself (You would likely need one per socket if there are multiple) that would track if an object is being held there or not. It can be changed when the player picks up or places an object on the socket. It would also be checked before these scenarios take place. This should just involve a few booleans and a few branch statements.

Good luck!

This worked out great, thank you for your help! :slight_smile:

Get Child Component / Is Valid

My solution to this problem.

Get all attached actors and see if there is already an instance of the same class attached.

1 Like

Yet another solution:
Get all attached actors, get array length, if it does not equal zero then something is attached: