lerp correctly the targets position using a lerp on the gamepad stick angle (-180 to 180 values)
My problem is that when I lerp the target using the gamepad stick direction which uses values from -180 to 180, when crossing that barrier it goes very quickly to the other value so the target does a very fast turn around.
What is the expected result
Doing a lerp with the target using the gamepad joystick direction
What is the actual result
When going from -180 to 180 on the values, obviously the lerp will do a very fast change of those values and I was wondering if there’s a way around this problem.
So, you can do this, but know that generally you don’t lerp player input like that. You might run into players feeling like the controls are unreponsive.
That said, just add 360 to your totals. Angle increases infinitely. 360 is the same as 720, so -180 would become +180, +180 would become +540, which are visually the same.
Basically just add +360 to the end (or 360+ to the start) of your expressions. Only once per action.
This doesn’t work unfortunately. I did try it. even if I add 360 to the values there will always be an angle of the gamepad stick where the extreme values will change abruptly. In your case if I add the 360, it will happen between 180 to 540 and from 540 to 180. Because of how the input of the gamepad gives these values. But I understood your way of thinking. If I could add or subtract 180 to the input values each time the stick goes to those values maybe that would work. Perhaps a bit of coding is needed on this one
I solved this by not lerping the input like you said and simply lerping a 2nd target to the position of the original target. Works like a charm now. Thanks for that advice
I’m glad you found a solution, apologies for the confusion as I misunderstood your specific issue and posted way too late in the AM.
Your method will definitely work, and to do what I was thinking you’d need to add the +360 to only one side of your events along with checking the current position (e.g. if cursor is >0 and currently at < 180, and it is flipped, add 360 to the total. if it is > 180 and it is flipped, don’t add 360, etc.)
Which is way heavier than the method you came up with. Rotating to a position rather than angle will be the easier method, yes.
That’s awesome to know! Thanks very much. In the meantime I solved it in another way but your answer will probably help other on here. Going to mark this as solved