[Request] C++ Character.h SetBase definition please

I want to set the base of a Class I have that extends AActor. I intend to move another AActor about and want this one to move with it.

Can a Epic dev show the definition of this function declaration please?

/** Attaches the RootComponent of this Actor to NewBase, and sets the replicated Base Actor to the owner of NewBase (or the WorldSettings if NewBase->IsWorldGeometry()) */
	virtual void SetBase(UPrimitiveComponent* NewBase, bool bNotifyActor=true);

Dear Michael,

The answers:

Attach to specific component of another actor

ActorToBeBased->AttachRootComponentTo(ActorBase->SpecificComp_Like_StaticMeshComponent);

or

Attach to another actor, with socket/relative offset options

ActorToBeBased->AttachRootComponentToActor(ActorBase); 
//optional socket name
//option to keep the current relative distance between the actors

_

Hope this helps :slight_smile:

Rama

I wanted to copy the implementation of SetBase that is in Character, can’t look in the .cpp file. I don’t want this for a Character, I have an Actor that is bluprinted to hold together a whole mess of particaly effects, skeletalmesh and light that the Artist made. I want to attach this whole thing to another Actor, also not a Character that will be relocated.

Actor does not have SetBase so it won’t compile as you show.

The answers:

Attach to specific component of another actor

ActorToBeBased->AttachRootComponentTo(ActorBase->SomeSpecificComponentLikeStaticMesh());

or

Attach to another actor, with socket/relative offset options

ActorToBeBased->AttachRootComponentToActor(ActorBase); 
//optional socket name
//option to keep the current relative distance between the actors

Well then that explains James Golding’s answer :slight_smile:


You can use GetRootComponent() and

AActor.h

line 573:

 UFUNCTION(BlueprintCallable, meta=(FriendlyName = "AttachActorToComponent", AttachLocationType="KeepRelativeOffset"), Category="Transform|Actor")

void AttachRootComponentTo(class USceneComponent* InParent, FName InSocketName = NAME_None, EAttachLocation::Type AttachLocationType = EAttachLocation::KeepRelativeOffset);

ActorToBeBased->AttachRootComponentTo(ActorBase->GetRootComponent());

or just use

00583:
    UFUNCTION(BlueprintCallable, meta=(FriendlyName = "AttachActorToActor", AttachLocationType="KeepRelativeOffset"), Category="Transform|Actor")
    
     void AttachRootComponentToActor(AActor* InParentActor, FName InSocketName = NAME_None, EAttachLocation::Type AttachLocationType = EAttachLocation::KeepRelativeOffset);
    00584:

If you want to attach an Actor to something else you can use AttachRootComponentTo or AttachRootComponentToActor.