direction of character when entering a new room

Started by , Sat 05/11/2005 11:18:49

Previous topic - Next topic

PennyLane

Hi,

how do I change the direction my character is facing on entering a new room?

Example: The character walks out of one room at the top edge, thus Loop 3 (up) is used. But he enters the new room on the right edge, thus Loop 1 (left) should be used but it's still Loop 3.

Thanks for helping,
PennyLane

Ashen

Use the Player enters room (before fade-in) interaction, and either Character.FaceLocation(x, y) or directly alter the Character.Loop property.

If you haven't already, take a few (alright, a lot more than a few) minutes to read through the manual. Just knowing the names of some of the commands and properties makes it easier when you come to asking yourself "How would I do ...?"
I know what you're thinking ... Don't think that.


Tamanegi

I'm not making a new thread because my question is a direct followup of the opener's:

What can I do if the room can be entered from various directions, but the camera in adjacent rooms doesn't face the same direction as the one in that room, and I want to specify a facing upon entering from each direction?

I tried changing the facing directly after the line changing the room in the script, but it did nothing; I also tried changing the facing directly before the line for room change, but that gave me a runtime error.
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

Creator

In the previous room make the character face the location before changing rooms, but make sure it's a blocking script (which always works for me).

Code: ags

player.FaceLocation(player.x-1, player.y, eBlock); //Player faces left
player.ChangeRoom(2);

Tamanegi

That works, but it's a little ugly because the turning is still visible before fade-out...

My next idea would be a global variable that stores the ought-to-be orientation in the next room and a script in that room that turns before fade-in, but I'd rather use an ordinary command if there's one that is suited.
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

Creator

Perhaps this might work:

Code: ags

//Player enters room before fade-in
if (player.PreviousRoom == 1) {
  player.FaceLocation(player.x-1, player.y); //Face left
}
else if (player.PreviousRoom == 2) {
  player.FaceLocation(player.x, player.y+1); //Face down
}
//etc.


I pretty sure blocking scripts cannot run before fade-in so you should leave it as a non-blocking command.

Tamanegi

That works great! I didn't even know there is something like "previousroom"...  ::)
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

OneDollar

I think you can just do
Code: ags

player.ChangeRoom(2);
player.FaceLocation(player.x-1, player.y, eBlock); //Player faces left

The FaceLocation seems to get run after the room fades out, but before room 2 fades in, at least it worked that way for me

Ashen

Quote
I didn't even know there is something like "previousroom"...

Which is why you're supposed to read the manual before posting questions.

ChangeRoom is a 'queued' coomand - it doesn't run immediately, but is executed at the end of the block of code it's called in. (This is also in the manual ;)) So, in effect, OneDollar's code and Creator's are the same, and would have the same problem. Using player.PreviousRoom is a much neater solution anyway.
I know what you're thinking ... Don't think that.

Tamanegi

#10
Quote from: Ashen on Fri 21/12/2007 10:49:42
Quote
I didn't even know there is something like "previousroom"...
Which is why you're supposed to read the manual before posting questions.

Which I usually do, but reading the whole manual without having an idea what you are looking for is like trying 20 items with 30 hotspots and hoping something useful happens  ;)  It's very hard to memorize everything in the manual at one time.

But I know what you mean, some questions posted here have really obvious solutions. Thank you for answering all our newbie questions so patiently!  :D I hope to be able to reward you soon with a nice game!
Don't Look! MAGS 12-2010
Mediocre Expectations Current development blog

SMF spam blocked by CleanTalk