Announcement

Collapse
No announcement yet.

Actor Parenting Issue (C++ -> World Outliner)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Actor Parenting Issue (C++ -> World Outliner)

    I have two custom C++ actors that I am creating from code that show up in the world and World Outliner.

    However, I'm trying to get things more hierarchical.

    I'm trying to add ubody to ubiped as a child actor in the Outliner, but it isn't working.

    Code:
    ubody->AttachToActor( ubiped, FAttachmentTransformRules::KeepWorldTransform );
    What's the proper way to change an actor's parent in the scene from C++?

    #2
    It probably has attached, but because you're using ''FAttachmentTransformRules::KeepWorldTransform" the object you are attaching stays where it is.

    If you want the object to move to the thing it's been attached to, use SnapToTarget instead.

    Comment


      #3
      Originally posted by TheJamsh View Post
      It probably has attached, but because you're using ''FAttachmentTransformRules::KeepWorldTransform" the object you are attaching stays where it is.

      If you want the object to move to the thing it's been attached to, use SnapToTarget instead.
      I tried SnapToTarget without success.

      I mean in the World Outliner. This is how it is currently...
      Click image for larger version  Name:	Clipboard01.jpg Views:	0 Size:	15.1 KB ID:	1769904

      But I'm trying to get the _head to be shown as a child of the BipedActor. Like these...
      Click image for larger version  Name:	Clipboard02.jpg Views:	0 Size:	13.6 KB ID:	1769905

      Comment


        #4
        My initial question is why are you assembling objects in the scene outliner instead of blueprinting them? I can understand if you're parenting a wall to a floor or something, but parenting a head to a body sounds like something that should be done in asset form, not in the level directly.

        I can't tell you why it's not attaching to be honest then, it's going to be something specific to your setup.

        Comment


          #5
          the world outlier also has filters that you can change to show "hidden actors" and other such things sometimes you need to change filters to see components.

          Also components can be weird. some components ive found out will only properly work as the root component.
          and certain attributes get cleared after the constructor so you have to move them to begin play instead.

          Comment


            #6
            Originally posted by TheJamsh View Post
            My initial question is why are you assembling objects in the scene outliner instead of blueprinting them? I can understand if you're parenting a wall to a floor or something, but parenting a head to a body sounds like something that should be done in asset form, not in the level directly.

            I can't tell you why it's not attaching to be honest then, it's going to be something specific to your setup.
            The scene is actually being built up from C++, it's a port of an OpenGL/Bullet Physics game.

            The game basically builds separate rigidbody objects/actors, connects them with constraints, and then creates a poseable mesh to actually have the skinned mesh geometry.

            Comment


              #7
              Originally posted by ViperG View Post
              the world outlier also has filters that you can change to show "hidden actors" and other such things sometimes you need to change filters to see components.

              Also components can be weird. some components ive found out will only properly work as the root component.
              and certain attributes get cleared after the constructor so you have to move them to begin play instead.
              Doesn't solve my question, but these were some really helpful tips, especially the filter, thanks!

              Comment


                #8
                Are they spawning at the correct xyz transform? just not attaching ?
                and when are you attaching them? after its been created w a reference or during the begin play?

                Comment


                  #9
                  Originally posted by ViperG View Post
                  Are they spawning at the correct xyz transform? just not attaching ?
                  and when are you attaching them? after its been created w a reference or during the begin play?
                  Yeah, everything is correct in world/xyz space transform. Just not attaching as far as the World Outliner reports. I'm trying to attach them just after they have been creation.

                  Comment


                    #10
                    Try creating the actor in BeginPlay of the parent actor (ubiped):

                    1st step is to spawn you child actor inside your parent actor, beginplay is a good spot
                    2nd step is to attach with a transform option, snap or keep or world, then set the x,y,z if needed or skip that part.

                    Code:
                    FActorSpawnParameters SpawnParams;
                    SpawnParams.Owner = this;
                    ubody = World->SpawnActor<AActor>(ubody_class, FVector(0.f), FRotator(0.f), SpawnParams);
                    ubody->AttachToActor(this, FAttachmentTransformRules::KeepRelativeTransform);
                    ubody->SetActorRelativeLocation(FVector(0)); //spawn at origin point of parent actor

                    Comment

                    Working...
                    X