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?
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…
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();