How can I keep Control Rotation from freaking out past 90 degrees?
Hi, I'm gone through and setup an inverted sphere world where the control rotation's up vector always points towards the world's center (0,0,0). The player can walk around on the inside of the sphere all the way around, but currently when the player hit's the 90 degree mark of the world the control rotation starts to fall apart. This effect actually starts to occur before 90 degrees (maybe around 75-80) but it's a gradual transition. I've test my walking past 90 degrees on the two working halves of the world ( below the 90, and above) by placing the character upright on the bottom half and then upside down on the top half. The character will fall along his UpVector and then can move along the walls until hitting this point. There's a big chance it's still something burried in the CharacterMovementComponent that I haven't rooted out yet but my gut tells me it's some sort of rotation math issue. Right as the player hits this 90 degree mark the control will sort of spin/ fall over, it feels as though some value is no longer staying within scope. When I slam into this invisible barrier the character will bounce out off the surface and then start to inherit it's Local Z is down gravity setup, and sometimes it'll float over the barrier and allow me to drop down to the ground on the other side (It's actually kind of cool). Again I'm not convinced it's not still a lingering evaluation in my charactermovementcomponent but the fact is that the control mechanism that I've setup in BluePrint loses it's effectiveness around this 90 degree limit, and I don't understand why something that is pointing at a location every tick can wobble out of alignment and break, so I'm looking for some suggestions about where to look. Ultimately I think I should throw away the Blue Print and just embed this stuff in the CharacterMovementComponent, but that'll be easier once I know what is going on. Attached is shot of the actual BP keeping the UpVector pointed towards the world (0,0,0) vector.
asked Jun 21 '14 at 03:14 AM in Blueprint Scripting
The answer from Lina is how I got it to work.
This stopped the camera from wobbling as I approached the 90 degree mark (eventually turning/ flipping over onto the character's head as the gimbal lock set in). This also stops the control's turning from reversing on the other hemisphere.
The problem with Euler rotation system is that it isn't continuous when you change more than 2 components, and it causes gimbal lock issue.
1) Get rotation vector from player as you did up there (pitch and roll with 0 yaw)
2) Get the yaw value you want as the above graph (yaw)
3) Now rotate the vector from 1) with 2) rotation
4) Now convert that vector back to rotator and set to player
This will rotate the original rotator to "yaw" rotator you want, and give the final rotation back.
answered Jun 23 '14 at 09:36 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here