I will have several doors in my game so I created a function that I will call that will open and close my doors. Later when I get to adding sound I will put that in the one spot and will work for all my doors. All of my doors have a 5 image(frames numbered 0-4) animation for opening and closing. When a room loads I set the view for the door and then when the player wants to open or close the door I just call the function. When the door is open there is another walkable area that is enabled that allows them to go through the door. It is disabled when the player closes the door. This is where the problem occurs.
Code: ags
My problem is when the walkable area is removed and then i call player.PlaceOnWalkableArea sometimes it works sometimes it doesn't.
I have walkable area #1 always available so its not like it can't find a walkable area.
EDIT: I have even tried putting the player.PlaceOnWalkableArea() call in the repeatedly_execute function and verified that it is being called.
static function OpenDoor(Object*obj, int WalkableAreaToEnable) {
if (obj.Frame==0) {
obj.Animate(obj.Loop, 5, eOnce, eNoBlock, eForwards);
if (WalkableAreaToEnable!=0) RestoreWalkableArea(WalkableAreaToEnable);
}
}
static function CloseDoor(Object*obj, int WalkableAreaToDisable) {
if (obj.Frame==4) {
obj.Animate(obj.Loop, 5, eOnce, eNoBlock, eBackwards);
if (WalkableAreaToDisable!=0) RemoveWalkableArea(WalkableAreaToDisable);
player.PlaceOnWalkableArea();
}
}
My problem is when the walkable area is removed and then i call player.PlaceOnWalkableArea sometimes it works sometimes it doesn't.
I have walkable area #1 always available so its not like it can't find a walkable area.
EDIT: I have even tried putting the player.PlaceOnWalkableArea() call in the repeatedly_execute function and verified that it is being called.