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
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.