Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: glurex on Thu 20/10/2022 01:57:02

Title: [Solved] Face Location in Scrolling Room.
Post by: glurex on Thu 20/10/2022 01:57:02
Hi :)

I realize I have a problem with "face location" in scrolling rooms (in "normal" rooms it works great). I set FaceLocation to get coordinates from mouse, so when the cursor interacts with something like a character, hotspot, object... in some specific side of the room the player character turns that direction.
I suspect that this problem in scrolling rooms have to do with room coordinates being different to screen coordinates. So instead of the classic

player.FaceLocation(mouse.x, mouse.y);
I write this:

player.FaceLocation(mouse.x - (Game.Camera.X), mouse.y - (Game.Camera.Y));
But didn't work at all, and now I'm pretty confuse about it  :-\




Title: Re: Face Location in Scrooling Room.
Post by: Crimson Wizard on Thu 20/10/2022 02:06:16
It should be
Code (ags) Select
player.FaceLocation(mouse.x + (Game.Camera.X), mouse.y + (Game.Camera.Y));
Title: Re: Face Location in Scrooling Room.
Post by: glurex on Thu 20/10/2022 02:25:42
Quote from: Crimson Wizard on Thu 20/10/2022 02:06:16It should be
Code (ags) Select
player.FaceLocation(mouse.x + (Game.Camera.X), mouse.y + (Game.Camera.Y));

Many thanks CW!  :-D
Title: Re: [Solved] Face Location in Scrolling Room.
Post by: Khris on Thu 20/10/2022 08:00:25
Screen coordinates are limited to the screen size while a scrolling room's coordinates can be much larger. Therefore you need to add the camera coords to go from screen coordinates to room coordinates, subtract them to go from room to screen.

And no need to put Game.Camera.X in parens btw.
Title: Re: [Solved] Face Location in Scrolling Room.
Post by: glurex on Thu 27/10/2022 21:04:17
Quote from: Khris on Thu 20/10/2022 08:00:25subtract them to go from room to screen.

Thanks! Now I understand what I was doing wrong.

Quote from: Khris on Thu 20/10/2022 08:00:25And no need to put Game.Camera.X in parens btw.

That's right, good observation. It was a remainder of a primitive idea (I wanted to add some pixels of "distance", but later I discarded that idea.) and I forgot to remove them.