Hello Everyone of the Angelscript Forum,
I am back with yet another weird situation. I am sure you guys know the answer to this one. I am baffled right now. ?
So, I am trying to get a camera in a 2D game follow the player with smooth movement. I got the camera following with smooth movement part working, but the problem I have now is that the player character is at the top left corner of the screen. I cannot seem to get the camera to center the player to the screen. I am not sure what to do. The camera smoothing part is working! How do I get the camera to be over the player character so he is near the center of the screen?
Here is my code:
float time = UnitsPerSecond(10.0f);
float lerp = 0.1f;
vector2 position = GetCameraPos(); <- I think this is a problem because to center the camera on player, I would need this to say "vector2 position = PlayerPos - ScreenSize / 2". But if I use that code with PlayerPos - ScreenSize/2 the camera becomes jittery, but I dont understand why that happens?
position.x = position.x + (player.x - position.x) * lerp * time;
position.y = position.y + (player.y - position.y) * lerp * time;
print(position.x);
SetCameraPos(position);
Anyone have an idea on what im doing wrong here?
Thank you,
DrMeowEyes