Hiya.
I am trying to set an actor's rotation based on an average rotation over the past few frames and having a bit of trouble.
Each Tick the actor's current rotation is appended to an array of type Rotator, and the first item in the array is knocked off while the others are shifted up a position. The contents of the array are all added up into a single rotator, then divided by the number of frames/items in the array, which gives me an average. The actor's rotation is then set to that average rotation value.
That all works 100% perfectly, EXCEPT when the actor rotates around an area where the Yaw is near 0 and 65535 (where the Yaw value 'ends' and 'starts'). That's becuase the rotation is now being average'd out over a range of 65535 and 0, so when the array is added up and divided, it ends up with a rotation of exactly opposite what to it should actually be for a few frames, creating a really nasty flicking effect.
I have tried using Quat rotation based on functions found in the Wiki, but found you can't add multiple Quats together, and therefore I can't get an average. I have little to know knowledge in this area though, so maybe there is something I am missing here.
Any suggestions or help would be appreciated, thanks.
I am trying to set an actor's rotation based on an average rotation over the past few frames and having a bit of trouble.
Each Tick the actor's current rotation is appended to an array of type Rotator, and the first item in the array is knocked off while the others are shifted up a position. The contents of the array are all added up into a single rotator, then divided by the number of frames/items in the array, which gives me an average. The actor's rotation is then set to that average rotation value.
That all works 100% perfectly, EXCEPT when the actor rotates around an area where the Yaw is near 0 and 65535 (where the Yaw value 'ends' and 'starts'). That's becuase the rotation is now being average'd out over a range of 65535 and 0, so when the array is added up and divided, it ends up with a rotation of exactly opposite what to it should actually be for a few frames, creating a really nasty flicking effect.
I have tried using Quat rotation based on functions found in the Wiki, but found you can't add multiple Quats together, and therefore I can't get an average. I have little to know knowledge in this area though, so maybe there is something I am missing here.
Any suggestions or help would be appreciated, thanks.