How to add a rotation relative to a component's parent?

I am trying to make a component that orbits around its parent. I do know how to perform this operation using some vector math, but I am trying to understand more about the engine. I have setup a simple Blueprint class with a CubeComponent that has an offset relative the the DefaultSceneRoot component

I then setup my Event Graph to check the behaviour of AddRelativeRotation, AddLocalRotation and AddWorldRotation. But all these functions give the same result, my cube is rotating around itself, even with AddWorldRotation. I even looked at the USceneComponent::SetWorldRotation and the code seems to be ok.

So, is my Event Graph supposed to work or do I need to do the math to get the orbiting behaviour?

102546-componenets.png

One approach would be to use a spring arm - essentially the same idea as the camera boom - to drive the rotation. This could be centered at the point of origin for the parent object, then have the child object at the other end. Then, just rotate the spring arm instead of the object itself.

Of course, there are probably a half dozen ways to get the behavior you want - vector math, updating location based upon a rotator, etc. - but I think this is probably the smoothest way to handle it. It will also allow you to keep what you’ve done so you can get self-rotation as you have it and an orbiting rotation at the same time.

Thanks for the tip. I was considering the SprintArm component but I was questioning about the expected behaviour of AddLocalRotation and AddWorldRotation. My point is that they are doing the exactly same thing.

Do you know in which circunstancies they will behave differently?

Hi mcleary,

Try creating a separate actor that contains a rotating movement component. You should be able to call this as a child actor of the primary blueprint within the blueprint components viewport. You can use a spring arm as suggested to increase the distance around the initial actor that the child actor rotates.

Adding rotation value should always just… add it to whatever it is. I don’t know why local or world would be different. I suppose the only difference would be in retrieving its local or world rotation values, but visually, I image it’d always be the same. Definitely curious about this, if there are situations where, visually, they would be different.

I think that the AddLocalRotation is meant to add a rotation the object’s local rotation axis and the AddWorldRotation will add relative to the canonical axes.

The names fooled me this time. I was thinking that the rotations’ pivot should be the object’s parent. I think that I should find a way to change the Rotation’s Pivot for the sake of curiosity.

The simplest approach I found is to add a scene component to the parent component. The scene component will act as a pivot for the rotation of its own child components.