My game has a tall 400px background.
I want to lock the ViewPort's Y depending on what half of the screen the player is on, so the half of the background is only in view.
I moved the Top and bottom edges to the center of the screen, and added this:
function room_LeaveTop()
{
SetViewport(player.x - 160 , 0);
}
and
function room_LeaveBottom()
{
SetViewport(player.x - 160 , 200);
}
This works like a charm, except it makes the player character vibrate when moving horizontally which is a deal breaker.
Is there a way to only set the Viewport's Y, and have X behave normally so it scrolls with the player?
you could put in Rep_Exec:
if (player.y<200) SetViewport(player.x - 160,0);
else SetViewport(player.x - 160,200);
Quoteyou could put in Rep_Exec:
This works the same as what I had, however the character still vibrates while moving horizontally.
I'm fairly certain the problem is in the SetViewPort function, not where the function is.
Is it possible to set the Viewport Y without setting the X?
Quote from: Glenjamin on Wed 04/10/2017 21:21:37
Is it possible to set the Viewport Y without setting the X?
Technically this:
SetViewport(GetViewportX(), y);
you will tell it to keep X that it has. But the issue here is that by setting a viewport you are taking control over camera from AGS, and it no longer automatically moves it, so that will defeat the purpose.Actually that's dumb anyway, so disregard that.
Considering character vibrating, I may propose to move the code into "late_repeatedly_execute_always" and see if that helps. IIRC that helped me in the past.
QuoteConsidering character vibrating, I may propose to move the code into "late_repeatedly_execute_always" and see if that helps. IIRC that helped me in the past.
This worked perfectly! animation is smooth and the camera movement works.
Thanks!