Hey guys, I’m not sure if this is possible, but I’ll ask anyways.
I have a float that needs to stay in the range of -1.0 and 1.0 with random increments and decrements. The -1.0 to 1.0 represent direction, same as 360 degrees. The way Clamp works is that when it reaches one side of the limits it returns that limit.
Is there a way to wrap around the remainder? Perhaps I should be using modulus to get the result I need?
You could simply use the Rotator to do that for you. just use either one of the 3 components (Pitch/Yaw/Roll) and you can use Rotator functions to clamp, interpolate etc and then if needed you can divide it to get a float value.
But if you really need to make it work with floats, you can use modulus operator to make sure the values stay within range and wrap around.
One question, suppose we start from -1.0 and add 0.5 in each step. So the series goes like this. What should be the one after 1.0? (ie 1.0+0.5)
Hey guys, Thanks for the help. I figured out a way get this done.
It might have helped if I specifically said where I was getting the -1 to 1 direction variable.
It was a normalized Vector.
So what I did was Denormalized the vector to a FRotator, modified the Yaw, then got a new vector from that.