Forum rules - please read before posting.

2 players, 2 way doors.

Alright. I have a point and click game with 2 players. (turn based)
I also have doors in the game that only open and close with the right items in a player's inventory. The way this works is that you interact with the door, walk up to it, and then the game checks for the item. If you have it, an actionlist starts to walk the player through the door and closes the door behind the player. 

I have been using a system for setting this up, and I want to sanity check if this is good practice, and if there are other ways to handling these types of doors.


Setup:
2 Triggers, left and right of the door.
1 moveable door object, with NO navmesh connecting both doors.
2 markers, one on each end of the door.
2 hotspots, both identically placed over the door.
1 bool per player, to keep track of whether the player in left or right of the door.
2 paths, one from the left marker to the right marker, and one the other way.

So typically in the OnLoad of the scene, I check the bool for the current player, and switch one of the hotspots on the door off, and the other on. This ensures that when I click on the door, the player interacts with the right hotspot, and thus walks to the correct marker and starts the correct interaction. The interaction typically ends with the player walking through the door. Starting a series of cutscenes which animate the moveable object, set the player on a path to the other side, closing the door again, and then stopping. 

On the other side of the door is a trigger set to 'Continuous'  which is triggered by a player, and sets the bool to 'IAmNowOnTheOtherSideOfTheDoor' and triggers the Actionlist which then toggles between which hotspot on the door is active now. And that's it. I use 1 bool per player to check if we are on the in or outside of each two-way door. 

This does however feel like a lot of management for a simple door. Not to mention the continuous triggers are kinda heavy on performance. Turning hotspots on and off every frame in a continuous trigger also causes flickering interfaces.

Does anyone have a better strategy? 



Comments

  • I might be wrong, not seeing the scene for myself, but you might be able to get away with just one Hotspot and no Triggers.

    Since you're using a boolean Variable to determine which side of the door the player is on, you can check that value in the Hotspot's Interaction to either move the player to the left side or the right.  When the interaction is run, you can then set the variable to the new correct value at the end of it - avoiding the need for Triggers.

    If you have several doors that need this, look into using Action parameters - this'll save you a lot of time when building interactions that basically do the same thing, just with different objects/markers etc.
  • The problem with using 1 hotspot like you suggest is that the checking of the bool and the walking to the correct marker part has to be done in a Cutscene. This in turn takes the control away from the player to cancel the walking interaction, and also results in the player avatar ignoring any triggers that might be in his path. Which for my game breaks quite a few puzzles.

    What I ended up doing now was a bit different. I did remove most triggers. I kept the 2 overlapping
    hotspots per door. But instead of having 1 bool per door, i made an int per player to keep track of the room number he is is. Every time the player moves through a door, I switch to the new room ID. Then I run a Cutscene which, based on the current room number, changes which of the hotspots of other 2-way doors in this new room is active. This makes sure all the 2-way doors in this room are now approached from the right side. Also, since the walking towards those hotspots is done in the hotspot settings and not the following interaction cutscene, makes sure the player can cancel the movement halfway through, and that the player avatar doesn't ignore triggers.

    The cutscene that sets the correct door hotspots based on roomnumber grows to be pretty big over time, but I only have like 4 2-way doors per level, so it works OK for me.

    It gives me quite a bit of control also. I had a problem with the player interacting with hotspots on the other side of a closed room, on a piece of navmesh pathfinding couldnt reach. They player would walk as close as possible as the pathfinding would allow to the marker of that hotspot and just start the interaction anyways, even though he wasn't at the destination marker! This was not what I want at all, but now I can just doublecheck if a player is in the right room to allow this interaction in the first place, which works for me. 

    And wow. Action Parameters. Never knew those existed.

    That would have saved me a huge amount of work, and made faults less likely. 
    I will be using those from now on for sure.



  • Are you aware that all ActionLists, including Interactions, can be set to run in the background?  They'll block gameplay by default, but changing their "When running" setting at the top can prevent this from happening.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.