Windows View not following object because of high speed

P

peceecar

Guest
Hello guys, so I have this 2d top down starship game and the thing is everything works fine for now but I use this code In the step event to follow the player because the player ship is almost always outside the room borders. The only problem is the player object often exceeds speeds of up to 5000-10000 and this sometimes causes the view to slowly lag behind the player as the ship accelerates slowly outside the view. Travel distance between planets is huge and I really want this to work with such high speeds (usually the player would choose 200-300 speed to avoid crashing into things and having better control) but even at those speeds the view still lags behind massively and I see the ship usually at the end of the view or outside. Anyway to fix this? I don't mind if it doesn't follow him smoothly the player just has to be always at the center of the view. Thank you.

This is the code in the step event that I use to follow the player:

view_xview = obj_player.x - view_wview/2
view_yview = obj_player.y - view_hview/2
 

JackTurbo

Member
Try shifting that code into the end step event.

What might be happening is that your camera control object might be centering the view on the player object before the player object has updated its position.
 
P

peceecar

Guest
Try shifting that code into the end step event.

What might be happening is that your camera control object might be centering the view on the player object before the player object has updated its position.
Thanks man that worked, can't believe it was something so simple I spent 3 hours fiddling around even with camera objects trying to make this work :D
 
Top