Debugging Blueprints with just faulty outcome

Hello everyone,

I wanted to ask a question in general even though I’m still new to UE4, but coming from Unity with quite a lot of experience.
I’ve read most of the documentation about debugging Blueprints (watch variables, breakpoints, Blueprint Debugger, etc.) but I couldn’t find a technique to deal with Blueprints that compile fine, execute fine, but just do not do what I’ve intended them to do.

As an example I want to show the following blueprint.

“Add Weapon” is called from a pickup when the player character walks into it. As a parameter, the pickup passes itself, because I want to carry it. I added a WeaponHolster socket to the Skeleton of the player.

The expected outcome was that the pickup would snap to the socket and move along with the player’s socket on the hand. The actual outcome is that the pickup snapped to the characters center position and just followed him, as if it was just attached to the rootTransform.

So my question is what a good workflow is to find out how to solve these kinds of problems? And by that I mean not this particular one, but in general. What do you do if all the nodes are set as you think they should be set, no errors, but wrong behaviour?

Obviously “Get Player Character” seems to be a valid input for AttachToActor, but will the socket be found since it’s part of a skeleton? How will I know?
Maybe it’s just ignored if it doesn’t exist, like the docs say about the “Socket Name”: “Socket name to attach to, if any”, but how can I be sure?

EDIT: I managed to attach it by adding a “GetMesh” node after the player character value and replace “AttachToActor” with “AttachToComponent”, viewing this video ([Attaching a weapon to a character][2])

So, ok, I could have guessed that I would the mesh to find a Socket, but why is it even possible to choose a socket name on a AttachToActor Node, when it’s impossible to pass a mesh into it?
This is just one of the questions that come up when you try reasoning something you did logically but for some reason still wrong.

Hi,

Well this is a tricky thing to debug because the code and logic is completely valid its just not what you require, you are right in thinking that it cant find that socket on the actor because there is no socket associated with that actor so it just attaches to the center, you need to attach to the SkeletalMeshComponent, I cant remember the exact syntax as not at my dev machine but I think there is an AttachtoComponent that will take the SkeletalMesh as a parameter.

These types of issues are just about investigating you logic like if your end result is not what you expect then go back to the start where processes/objects are born and follow the whole logic to the endpoint. remember though there is nothing wrong with the code the problem was with your understanding of the way the functions works so in this case researching how to attach to sockets would of been the approach but that’s in hindsight.

Hope this helps

Hi, thanks for the answer.
But then what DO i expect from AttachToActor with a socket name provided. What actor besides a skeletalmesh has a socket?

sorry like I said not at my computer so just going by memory but AActor::AttachToActor | Unreal Engine Documentation says “Attaches the RootComponent of this Actor to the RootComponent of the supplied actor, optionally at a named socket” so it should work if the skeletal mesh is the root component in the parent Actor.

ok, thanks. yes, that’s actually happening. Still, some things are a little misleading, but I guess that’s how it is.

So either have the skeletal mesh as the root component(the first component, usually the scheneComponent) in the parent Actor or use AttachToComponent.

Please mark as answered if it helped you.

Cheers