How to Rotate Object From Camera Angle?

So currently, I am using mouse movement to rotate an object when I hold down a button.

Particularly, this line for up/down mouse movement:
MeshRotationComponent->AddRelativeRotation((axisVal * BaseLookUpRate * GetWorld()->GetDeltaSeconds(), 0.f, 0.f));

However, when I turn the camera to look on the side, it still acts from behind. I have also tried using AddWorldRotation() instead, but I generally get the exact same issue, just on the world axis.

Here is a short clip of what it’s doing:

How do I get it to rotate “up” from the camera’s perspective?

so the `` has a pitch, roll and yaw and you’re only setting the pitch regardless of anything the camera happens to be doing

that is why it behaves that way.

i don’t personally know the best way of adjusting it, but adjust it you must!

Yes, this I am aware of, but I literally have no idea how to… I’ve done sketch work and tried to translate the idea, but how do I convert the rotation the camera is on, into a rotation in the correct direction? if the camera’s roll, pitch, and yaw is (0, 0, 90) and we want to move the object up by 20 degrees… how does (0, 0, 90) turn into (20, 0, 0) for the object? That’s what’s got me confused. Sorry for not clarifying in the question. I was hoping there was just a method already in place that I was ignorant about.

idk if this is the correct way but you could create an FVector with the current values you are using for your , then call the RotateAngleAxis function to rotate the vector about the Z axis relative to the camera’s current rotation, then you can convert that vector in to an afterwards

RotateAngleAxis is close to what I’d need, but it returns a vector direction and a Vector’s Rotation() has no Yaw value as it can’t calculate Yaw from a vector…

I tried this:

FVector rotation = MeshRotationComponent->GetRelativeLocation();
rotation = rotation.RotateAngleAxis(axisVal * BaseLookUpRate * 
		GetWorld()->GetDeltaSeconds(), CameraComponent->GetForwardVector());
		
MeshRotationComponent->AddRelativeRotation(rotation.Rotation());

As well as it’s world counterparts. It either did not move, or did… this…

If there is a way to add rotation on a vector axis, that would be ideal.

Welp, turns out you can do it through FQuat.

found a method called UKismetMathLibrary::RotatorFromAxisAndAngle() which returns a rotator rotated on axis. When looking at how it works, it simply does this:
return FQuat(SafeAxis, FMath::DegreesToRadians(Angle)).Rotator();

Hope this helps anyone in the future.