Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: updoggg on Wed 30/07/2025 01:13:41

Title: Help with cursor&moving with right click
Post by: updoggg on Wed 30/07/2025 01:13:41
hey, so i wanted to make it so you have one all purpose cursor where you interact with left click and then move on right click
this is the code -->
function on_mouse_click(MouseButton button) {
 
  if (IsGamePaused() == 1) {
    return;
  }

  if (button == eMouseRight) {
    player.Walk(mouse.x, mouse.y);
  } else if (button == eMouseLeft) {
    Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
  }
}

it works, but the issue is that in certain rooms it just doesn't, and the player can't go past a certain point for seemingly no reason? i know its an issue with the right clicking part because it works when i use arrow keys. help appreciated :o)
Title: Re: Help with cursor&moving with right click
Post by: Khris on Wed 30/07/2025 07:20:29
For scrolling rooms to work you need to add the camera offset (i.e. convert the mouse's screen coordinates to room coordinates).
  player.Walk(mouse.x + Game.Camera.X, mouse.y + Game.Camera.Y);