Skip to main content
added 18 characters in body
Source Link
Philipp
  • 123.1k
  • 28
  • 264
  • 344

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card and the resolution of its effects. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible during that state. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card and the resolution of its effects. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card and the resolution of its effects. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible during that state. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

added 263 characters in body
Source Link
Philipp
  • 123.1k
  • 28
  • 264
  • 344

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card, animate and the effect resolution of its effects. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card, animate the effect resolution. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card and the resolution of its effects. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

added 263 characters in body
Source Link
Philipp
  • 123.1k
  • 28
  • 264
  • 344

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. All other controls are inactive or disabled. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card, animate the effect resolution. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. All other controls are inactive or disabled. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana.
  • During the "execute card" state, you play the animation to play the card, animate the effect resolution. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

I try to use a while loop or a coroutine to essentially pause execution until a user clicks a button

This approach won't work. If you pause the execution of your game, you also pause the renderer, UI system and everything else the engine does. Even if you could force the engine to immediately render the button (it will only want to do that for the next frame), the player couldn't click on the button because the event system won't have an opportunity to process the click until your update has finished.

What you should do instead is use the concept of different game states.

  • During the "select a card" state, the player can click on any card in their hand attempting to play it. All other controls are inactive or disabled. When the player selected a card to play, the game switches to the "spend mana" state.
  • During the "spend mana" state, the 5 mana buttons activate for the player to click them. When the player spent enough mana, the game switches to the "execute card" state. You might also want to add some way to cancel the process and return to the "select a card" state without paying mana. All other controls are inactive or disabled.
  • During the "execute card" state, you play the animation to play the card, animate the effect resolution. All controls are disabled. When the card has finished, you return to the "select a card" state.

A good way to implement this in Unity is to put everything you need to be active for each state into a separate game object. This includes game mechanics scripts, spatial game objects and a separate UI canvas for any UI controls you want to be visible. When you switch from one state to another, set all state game objects to inactive and set the object for that specific state to active.

Source Link
Philipp
  • 123.1k
  • 28
  • 264
  • 344
Loading