A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Separate names with a comma.
Discussion in 'Open Projects' started by gregsolo, May 3, 2021.
Description and Steps to Reproduce on GitHub
Suggestions on how to fix below in this thread
I think this issue has 2 big parts:
1. We should make sure Player cannot be attacked while engaged in a dialogue
2. Player should not be able to start a dialogue when engaged in combat
The first one, I think, can be solved in different ways. Firstly, we could hardcode a rule into any attack, something like: "do not engage if dialogue is on". Sounds reasonable, but I'm more inclined to utilize `State Machine` we already have in place as much as possible and use `Condition` logic instead, which will allow Game/Level Designers to have full control over the situation
With that in mind, I suggest adding a new `Condition` that would be responsible for answering the question "Is there any dialogue open right now"?. Then we can use this `Condition` in the State transition. For example Slime Critter `Idle` -> `Alert` and "Roaming" -> "Alert" transition would be extended with this new Condition. Simply put: "Forbid transition to Alert if there is any active dialogue".
The logic behind this new `Condition` would be fairly simple: it will listen to the `DialogueDataChannelSO` channel, which is transmitted when the new dialogue starts or when dialogue ends. We could then preserve the boolean internal field `_isDialogueActive` which is changed to "true" when starting dialogue even fires, to "false" when end dialogue event fires. Finally, this `_isDialogueActive` would be the ultimate output of the `Condition. Statement`.
A few assumptions/possible follow-up issues:
1. I assume we are ok (for now, at least) with the fact that the enemy can start attacking as soon as dialogue closes. It can lead to some funny situations when roaming nearby Critter immediately attacks the Player after she/he closes the dialogue. As if Player was invisible all this time but now Critter can finally see her/him. We can address this in the next PRs
2. I also assume there is no way a Player can have more than 1 active dialogue at the time
I prepared this PR that utilizes suggested approach. Please let me know what you think
Hello @gregsolo ! I just merged the PR as mentioned on GitHub. Thank you
With the new condition(if the the character is not already engaged in a dialogue) to allow the slime critter to move from Idle or Roaming states to Alert state, this solves the first point you mentioned above.
However, currently if the slime is already on the Alert state, the player can still enter a dialogue which leads to your second point: Player should not be able to start a dialogue when engaged in combat.
That's why currently the team is working on a GameState manager SO that holds the current state of gameplay. The different states are: Gameplay, Pause, Inventory, Dialogue, Cutscene, LocationTransition and Combat.
We are on the combat state if there is an enemy nearby that is on the alert state. In this case the player won't be able to open Inventory or initiate dialogues. This should solve the second point
@Amel-Unity Thank you! Would it be possible to participate in this process?
In any case, here are a few ideas I have.
First, since we need to block interaction with the NPC if Player is in the Combat state, we should communicate this somehow to the player, for example via ui. When player collides with NPC, instead of "E Talk" button we could show "In Combat - Cannot Interact" msg.
Second, there is currently no clear indication that Combat is actually happening. We could use blinking red screen to communicate to Player that Combat is in progress (potentially adding combat music in future).
Both of this could be implemented, I think, before/in parallel with gameplay states. I could start working on this by just assuming "if any enemy is in alert mode, it means Combat".
What do you think?
Hey @gregsolo , sorry about the late reply. We had a couple of days off recently, we will get back to you Monday on this to share the progress. Thanks
No worries at all, enjoy your weekend
Hello! I hope you all here doing alright
Got a chance to review recent changes today and noticed `GameState` was introduced. This incredibly helpful, thank you!
Following up on this, I took a liberty to suggest next step towards blocking Player from starting dialogues during a battle.Here is the PR. I don't know if this is something that is already being implemented by internal team. If not, I hope this will be helpful
Next step I think should be actually setting game to `Combat` state when combat starts, happy to look into this
Added this PR that sets game state to `Combat` when slime critter detects player
Hey @Amel-Unity sorry to bother but is there any update on this?
Hi @gregsolo , Yes @ChemaDmk pushed some changes to main on the GameState but I believe it is still work in progress. Mentioning her here so she can share some updates on the topic
Hey ! Yes we're working on that. We have a GameState scriptable object that will prevent the enemies from attacking in certain cases. You can check the solution in Main.