'Normalising' GetWorldRotation to 0-360?

jamesonart
Tue, 08 Mar 2016 01:22:59 +0000
Blueprint

Hi guys!

So I’m setting up a blueprint to have a planet orbit a sun using a timeline.

Here is my blueprint:

Basically all it’s doing is lerping between the current rotation of the Earth (EarthRotation) and a location I’d like to have it (EarthOrbitSpeed) in over the period of the timeline. From there, when the timeline finishes I get the world location of the Earth and save that to a variable, and update the EarthOrbitSpeed variable, so when the timeline replays it just adds on to the previous values so it seemlessly rotates over and over again.

However I’ve run into a problem I didn’t take into account, which is I assumed that GetWorldRotation returns a value of 0-360, which it doesn’t. Seeing as how its range is -180 to 180, I get unwanted results since the math ends up wrong.

So my question is, is there a way to ‘normalise’ the GetWorldRotation values to be 0-360? Im sure the answers simple, so I thought I’d check here first.

I had thought of breaking a float in two and having seperate execs for each half of the cycle, but that’ll be my last resort.

I appreciate your time, thanks!

4 posts - 3 participants