Ignore attached actors rotation

I am spawning a object at runtime that I then attach to my main character in C++ with

KCircle = GetWorld()->SpawnActor<AActor>(KCircleActor);
KCircle->AttachToActor(this, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, EAttachmentRule::SnapToTarget, true));

In the details panel you can set rotation type to World (it defaults relative) so the rotation of the attached actor stays in world space and doesn’t rotate when my character rotates.

How do I set that in C++?

I thought this was set with the FAttachmentTransformRules, but it looks like that is only taken into account while actually doing the attachment and not afterwards like the rotation type.

I think what you are looking for is:

YourComponent->SetUsingAbsoluteRotation(true);

Rotation, Location and Scale have a function like this.

You can also set them in one go using:

YourComponent->SetAbsolute(bAbsLoc, bAbsRot, bAbsScale);
2 Likes

Thanks for replying.

Unfortunately my object is an Actor which does not have SetUsingAbsoluteRotation.

Now I’m thinking about it, there is no reason I couldn’t use a component and set SetUsingAbsoluteRotation.
I will have to take a look latter.

i dont know if you solved it but here is how to solve it, Gnimmel solution is working and i had the same issue as you, that my object is actor.
just get the root component of your actor and use (attach component to component) and attach your object root component to the other actor root component but before you attach make sure to (Set Absolute)

5 Likes