So I use the code below to generate a Yaw rotation value so I can make my characters spine face the direction pushed on the right stick.
FRotator MyRightStickRotator = RightStickDirection.Rotation();
MyRightStickRotator.Yaw -= 90;
const FRotator CameraRotation = FollowCamera->GetComponentRotation();
const FRotator YawRotation(0, CameraRotation.Yaw, 0);
MyRightStickRotator.Yaw += CameraRotation.Yaw;
The problem is, when I debug it, it gives me a value of 0 in the Xaxis, but then as I rotate clockwise it goes to 135, then -225, then around to -1 then 0. I was expecting it to go from 0-180, then -180 to 0.
How would I stop this from happening please?
Aren’t rotation amounts in radians? You are doing all your calculations in degrees.
Also, this line
MyRightStickRotator.Yaw -= 90;
and this line
const FRotator YawRotation(0, CameraRotation.Yaw, 0);
Aren’t doing anything in your code. You are overwriting, the first and not using the second…
Finally, the last part of the conversation in this thread should do what you need (you’ll need to re-write it as c++ obviously)
Hi, I’m making a shoot’em up in in the style of Beat Hazard. I’ve set up my character movement on my Xbox360 Gamepad Left stick and his rotation on my right stick. The problem is, if I hold my right stick for example on the right, my character...
Reading time: 3 mins 🕑
Likes: 2 ❤