What this currently does is rotate the turret (its individual sections, the Azimuth GameObject and Elevation GameObject) into a specific direction, which all works well, however I noticed the rotation to not be at a constant speed, instead it eases in at the end of its movement. How could I normalize these rotations to be at a constant speed? (Would like to point out, the turret is a child of another gameobject that can rotate freely around, which is why this code could possibly seem unnecessarily complicated at first, but its the only solution I was able to come up with so far)
Also its my first post here, hope Im doing it right
You’re using Lerp wrong. That said, that’s not your fault – pretty much everyone does, either accidentally or because they like the ‘wrong’ result.
Lerp takes a Start Point, an End Point, and a Percentage from 0.0 - 1.0. When given those, it has no easing in or out. You’re giving it a Current Point, an End Point, and a Speed. That’s what MoveTowards is built for.
Use MoveTowards with the exact same parameters and you’ll have the result you’re looking for.
Exactly, plain lerping is a static, absolute thing. Not a dynamic, relativistic one.
To use a lerp you need to know two end states apriori, in order to interpolate between them.
Most commonly, to produce a stable motion with lerp, one would have to know how long it would take, but this is impossible given that you’re incrementally going there and that your target (or start) is constantly repositioning.
Here’s an ok video about this (watched it to confirm it).
Did that (however with RotateTowards instead of MoveTowards) and it worked perfectly! Thanks a lot, your explanation of Lerp will also come in useful for sure.