Child Actor Component not attaching properly in Client

UE Version: 4.7 preview 2 (Launcher)

Hi there,

In my character I created a SetWeapon() function that adds a ChildActorComponent and attaches to character Socket. But as always, it only works on server. Client shows weapon but its not in proper location.

This is my SetWeapon function:

And this is BeginPlay event. For clients Im calling a Server RPC event.

And result. As you can see, Client does have weapon but not at Socket location.

Hi ryanjon,

I’m not able to reproduce this behavior here, but I did have to make a couple changes to make it work right and I want to see I’m understanding your setup correctly.

What I suspect is happening for you is that Clients are never actually running Attach Weapon, and instead what you are seeing is default value of Current Weapon on Clients. In my setup, I used an empty Current Weapon variable, so I avoided that issue. Is it possible you’re doing something different?

Your AttachWeapon is set to Run on Server. That looks like it will simply perform Set Weapon function on Server character again, rather than on Clients. If you remove Authority check in Set Weapon and run Attach Weapon off of Authority Check in Event Graph, you can run Attach Weapon as a Multicast. That’s what worked for me, at least, but maybe you’re looking to accomplish something else?

Perhaps you’re doing something entirely different, in which case a simple reproduction project would help us test this. If you’re able, could you upload one somewhere and let us have a download link? Thanks!

Hi ,

As you said i changed AttachWeapon event to Multicast but now clients have 2 weapons. One on socket position (as expected) and other at center (like in previous screenshots). And in my setup above, i too have Current Weapon as an empty variable added in Components Tab but since i am unable to add Classes to ChildActor directly in Blueprint, am using Add ChildActorComponent node.

Here is link to test project (created in 4.7.0 Preview 2 Launcher version).

Your BP_Cube is set to Replicate. Disable that and this should work fine. You don’t need to replicate it or its movement because you’re adding it as a component of Character BP, which is already replicated.

Also, it’s not strictly necessary to have CurrentWeapon as an existing component of Character BP. You can remove that, and instead create a variable of type Child Actor Component and set that from your Add ChildActorComponent node. Shouldn’t make much of a difference, but I figured I’d let you know =)

Hope that helps!

Thank you very much !! Works perfect now! :smiley:

One quick question. Why is not possible to set class of ChildActor in Blueprint? I was expecting to see a node called “Set Child Class”

Happy to help!

A separate node wouldn’t work, exactly, because Add ChildActorComponent is used to create a child actor of a specific class, and not a placeholder. node is, however, missing an input pin for class type, and we have a feature request in our system for that already. No word on when/if that will be implemented, but I’ll update request with this post so developers know there’s external interest in it.

Awesome! Thanks :slight_smile:

Answering there to show my interest for this missing pin as well. If it allows for dynamic choice of class to spawn. I would love it. (would simplify my whole vehicle swapping pipeline…)

4.16.2 pin has still not been added.
However, depending on your use case you could add an empty child actor component to your actor in advance and use “Set Actor Component Class” node to set class at run-time.