How to lerp/tween?

I’d like to smooth player rotation and camera movement using the lerp function. Can anyone explain in detail how this is done practically? I fiddled around with the function a lot, but so far have gotten no working results. Forum search just resulted in finding other people who where as confused as I am a few months ago. Also does someone know if lerp can be used for accelerating a projectile after it is fired? How exactly is this function limited? Does it work at all and if so for what and how?

Ok, curse of the unknowing dev at work here: The moment after you ask in a Forum you gonna figure it out yourself. Maybe this is helpfull for others:
Lerp needs those three values, the starting value, the goal you want to get to and the x that kinda defines how strong the lerp is. For a nice trailing camera you can do stuff like

lerp(CameraX("",0),player_entity.X(),0.03) lerp(CameraY("",0),player_entity.Y(),0.03)
to the camera x and y position, with player_entity being the thing you ultimately want the camera to focus on.

As for projectile speed and object turning it seems more comples, since you need starting values to work with. Lerping the turning of an object would use the current turnspeed as the a, the target speed you want it to turn as a b and then an lerp rate you’d have to experiment with. Since you can get angular velocity and average length of force of an object it might be possible to easily lerp object turning (as long as it has physics) and projectile speed (even if its not a physics object). This way you can also simulate velocity dampening and stuff. (Maybe even temporary dampen forces as long as something is in collision, even if its not a physics object? I don’t know, this might be possible without lerp anyways.)

[size=85]Sidenote: When changing direction control to angular velocity instead of rotation that somehow allowed my jet-craft to gain speed when taking sharp turns while boosting. Player can now speed-drift the craft. I love this engine! ^_^[/size]

1 Like