Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Peegee on Sun 25/09/2022 09:41:19

Title: Scroll blocking
Post by: Peegee on Sun 25/09/2022 09:41:19
Hello. For a beginning of level, I blocked the scrolling of the camera in x . The character could therefore move in x and y, but the auto tracking only worked in y, in height; Then I unlocked the auto tracking. I used this code for that:



function room_Load()
{
  Game.Camera.AutoTracking=false;
}


function late_repeatedly_execute_always()
{
   if (!Game.Camera.AutoTracking)
   Game.Camera.SetAt(800, player.y - 300);
}

For a new level, I want to do the same thing, but in y. That is to say that I want the camera to follow the character in x, so horizontally from left to right, but not in height. I try different parameters but it doesn't work, the auto tracking is not done in x. Someone would have any idea ?

function late_repeatedly_execute_always()
{
   if (!Game.Camera.AutoTracking)
 

   Game.Camera.SetAt(0, player.x + 940);
   
}


I risk being slapped with a wet trout but I can't get a nice display of codes in brown, yet I use and .

Title: Re: Scroll blocking
Post by: eri0o on Sun 25/09/2022 10:59:53
When you use Game.Camera.SetAt, it already will turn off auto tracking. But if you want to "follow in X", means the X position of the camera has to be a function of the player X position. And not following in Y, means the Y position is a function of something that isn't the player Y position.
Title: Re: Scroll blocking
Post by: Khris on Sun 25/09/2022 11:34:45
You're supposed to pass first x then y, so you probably need

Code (ags) Select
  Game.Camera.SetAt(player.x - 940, 0);
Title: Re: Scroll blocking
Post by: Peegee on Sun 25/09/2022 12:06:16
Yes !
It works (the character is at the bottom left of the screen), I don't really know how, I don't really understand these commands... But it works as I wanted, thank you !!


function late_repeatedly_execute_always()
{
   if (!Game.Camera.AutoTracking)

     Game.Camera.SetAt(player.x - 320, 930);
}