How do I disable mouse/cursor (clicks & hover) for player 2 during player 1’s turn in a turn-based card game?
I am making a turn-based card game with only mouse inputs. Player 1’s “hand” and “deck” are on the left, player 2’s are on the right. Both players share a screen, everything that occurs in the scene will show on both player’s screens exactly the same.
I have already built the game to work as a local 1v1 game where players take turn with the mouse. However I want this to be an online 1v1 game.
Currently, I have a boolean condition “Player2Turn”. This starts off false (player 1 goes first), when player 1 ends their turn, it switches to true. When player 2 ends their turn, it switches to false.
Interacting with (as in hovering or clicking on) Player 2’s side of the screen, as well as Player 2’s cards on the board, will only work when the variable “Player2Turn” is true. Same goes for Player 1, interactions with Player 1 (left)'s cards only happen when “Player2Turn” is false.
Currently it works in a local setting by taking turns with a mouse. However I want to set it up so that it works online.
Let’s say 2 players join the lobby. The first thing that happens when the game screen loads is that Player 1 is assigned as Player.1, and Player 2 is assigned as Player.2
Is there a way for me to essentially tell the game that, during all my events where “Player2Turn” is “True” is a condition, that all of the following mouse/cursor inputs/sub events will only work for Player.2?
Basically, when it’s player 2’s turn, I don’t want player 1’s mouse to have any effect on the screen.
"Player Number Identification:
Use “PlayerNumber” to identify which player is interacting with the cursor. For example, you can have an event that only triggers a specific action if the cursor is on an object and PlayerNumber is 1. "
But I’m unsure how to actually write this into the event sheet.
Seeing as I want to simply prevent Player 1 from being able to do anything during Player 2’s turn, would it work if I just:
At the start of each player’s turn, a big invisible sprite spawns taking up the whole screen and deletes itself after a frame. Whatever objects (cards, buttons, etc) have a collision with that invisible sprite will have their player ownership set to whichever player’s turn it is.
Would this work to disable interactions with the game entirely for player 1 during player 2’s turn?
Much appreciated - if you’d like to check out the game
It’s 2-player but there’s no playerbase yet, so in order to play it you may have to open the game in two windows and play against yourself (not much fun but it’s the only way to demo it right now)