Hello,
So basically I am making Interactive RPG, so user a choice in every decisions. So I am making conversation with enemy boss. In fight if enemy health is less than 20, then it triggers a conversation where boss surrenders and player have to choose to kill or not kill him.
I added 2 scripts - "Conversation Trigger" and "Usable" to enemy boss and another script to enable conversation trigger component as I set Trigger to "On Enable".
So conversation starts but player still can attack it due to that enemy dies. So player fails to enter in conversation. I don't know if this is correct approach, please give some suggestions.
Heres the code which enables Conversation Trigger:
private int getHealth;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
getHealth = gameObject.GetComponent<StatusC>().maxHealth - gameObject.GetComponent<StatusC>().health;
if (getHealth >= 80) {
gameObject.GetComponent<ConversationTrigger> ().enabled = true;
var anim = GetComponent<Animator>();
if (anim == null) return;
anim.SetBool("run", false);
gameObject.GetComponent<AIsetC> ().enabled = false;
}
}
I set it up similarly, but I used the script below (which is included in the example package).
I also added a Conversation Trigger set to OnUse on the boss:
It runs a conversation that sets a Dialogue System variable based on the player's response:
If the player chooses to let the boss live, the OnConversationEnd method turns off the boss's attack AI. The OnConversationStart and OnConversationEnd methods also pause the game during the conversation.