I’m trying to get a smooth camera effect where the camera is slightly behind the player and takes a few moments to catch up to him. For example, the player will be more towards the left side of the screen while the camera is moving left, and vice versa. Apparently the effect is called tweening, and the algorithm for it would be:
Where x is the position of the camera:
x += (target - x) * CONSTANT
It’s explained in this video: https://youtu.be/6cIN6iW5ois
The thing is, it’s explained in GameMaker while I’m making my game in Java. The code in game maker is:
view_yview[0] += ((y- (view_hview[0]/2)) - view_yview[0]) * 0.1
How would I translate this over to Java? I think I have most of it down, I’m just trying to find out what “target” would be.