Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FormosaFalanster on Wed 14/10/2020 11:54:09

Title: RemoveWalkableArea not working in function room_Load
Post by: FormosaFalanster on Wed 14/10/2020 11:54:09
hello, I have put a RemoveWalkableArea in the room_Load function yet the walkable area is still walkable. Note that the walkable area in question is located beyond the screen and character has to walk and scroll to reach it. It goes like this:
Code (ags) Select

function room_Load()
{
  RemoveWalkableArea (2);
}


The Walkable Area ID is correct so I am not sure why the Area is still active when the game starts.

PS in fact I added a player.Say in the room_Load function just to see if it would work and it doesn't, it seems the room_Load doesn't work at all.
Title: Re: RemoveWalkableArea not working in function room_Load
Post by: FormosaFalanster on Wed 14/10/2020 12:16:10
Well that was fast, some awesome person helped me in the discord channel, so for anyone who finds this topic in the search function with the same problem, the solution is to use the Enters Room event in the properties of the room, which in code gives this:
Code (ags) Select

function room_AfterFadeIn()
{
  RemoveWalkableArea (2);
}
Title: Re: RemoveWalkableArea not working in function room_Load
Post by: Slasher on Wed 14/10/2020 12:39:05
Lots of newbees do that so don't worry..

Always use the events panel if applicable...
Title: Re: RemoveWalkableArea not working in function room_Load
Post by: Khris on Wed 14/10/2020 13:45:07
That command should work perfectly fine in room_Load, the important thing is linking the function to the room events. Just creating the function won't work, AGS has to know to call it.
Title: Re: RemoveWalkableArea not working in function room_Load
Post by: FormosaFalanster on Thu 15/10/2020 11:40:37
Thanks for valuable advices guys. This game only has one room so it should be fine but I will keep this in mind for future projects.