Calling .walk() right after .setAsPlayer()

Started by Pogwizd, Sun 28/02/2021 16:37:58

Previous topic - Next topic

Pogwizd

Hi, I've got a question about how to script whole cut-scenes that involve changing rooms/characters and keep them in one function.

In my current code I am trying to change the room and the player at the same time and then make the character go to a certain position. So the code looks pretty much like this:

Code: ags

cSuper.SetAsPlayer();         
player.Walk(1334, characterYPos, eBlock, eWalkableAreas);


From the documentation I know that if the given character is not in the current room, .setAsPlayer() changes room to the one the new player-character is currently in. And this part works fine, however, if I add .walk() the game produces an error saying that "character not in current room".

If I display player.Room, it returns me the correct id (after the room change), so I don't really know why I am getting the error. I am assuming it's got sth to with the room not being fully loaded before .walk() is called (but this is just a wild guess of mine).
Is there a way to do this?

Thanks!

Matti

The script is being finished before the room changes which means you're trying to make the player walk in a different room which is not possible.

You should put the walk command in the script of the room the player changes to, most suitably the after-fadein-function.

Pogwizd

OK, good to know. Thanks for your help!


SMF spam blocked by CleanTalk