I’m building a simple game prototype where the player moves an actor on screen to collect other actors. When collected the actors attach to the player controlled movable actor.
As I’m testing right now balls spawn and falls with gravity. As the ball hits a collision shape on the movable actor the dropping ball is (1) set to not simulate gravity and (2) attached to actor. This puts the ball into a child of the player controlled parent.
Only problem is that the node attached actor does not move with the parent.
If I drag the same Blueprint ball to the scene, and make it a child to that same parent (by pulling it under the same player controlled actor) the child ball follows the parent.
What could be different when making an actor a child through the Blueprint node, compared to dragging it in the editor Outliner?
Do you think you could show your attachment code? There are some settings there you will want to make sure of- and are you using attach actor to actor, attach actor to component etc.
Typically you want to give the actor you’re attaching to some sockets, and that way the ball will have a dedicated place to stick!
I’ve left an unused node just to show that I’ve tried both Attach to Actor and Attach to Component.
I’ve chosen not to use slots as I assumed I’d need to predefine where the actual attachment would occur. I’d prefer it to be more dependent on the gameplay.
Adding to this from my solution search.
if I…
add a ball to the scene,
set it’s Simulate Gravity to FALSE,
play-in-editor,
pause the game,
drag the ball under the parent: making it a child
resume play-in-editor,
The newly added ball follows the parents movement (as it should), and it also have the Sphere component as a child under the DefaultSceneRoot component:
Perhaps, then, it’s the spawning of the ball that is where the error happens.
And since both balls that are behaving correctly have their sphere component as child under DefaultSceneRoot, perhaps that’s what’s causing it?!
Yes, the Default Scene root is basically the core of the actor. The sphere is just a static mesh component, if you attach the ball to something what you’re attaching is the root, which means the root and all of its children. You almost always want everything on an actor with the root as its highest parent.