Page 1 of 1

Increment on Destroy

Posted: Fri Dec 28, 2018 7:14 pm
by pegassy
Hello,

I was using Increment on Destroy script in the previous versions of my project. Now with the new Dialogue System Trigger Interactable script, is there an easier way to do this?

Namely, I would like my hostile characters to trigger an incremental increase on a given variable when they are dead, but I do not want to disable their bodies from the game. There may we workarounds (such as assigning the increment script to a different object, etc), but I was hoping there would be a more direct way to do this.

Re: Increment on Destroy

Posted: Fri Dec 28, 2018 8:24 pm
by Tony Li
You could set a Dialogue System Trigger to OnUse and manually call DialogueSystemTrigger.OnUse when the character dies. Add a Run Lua Code action to increment the variable. You can use the math.min() function to limit the value. For example, to limit a "kills" variable to a maximum of 3:

Code: Select all

Variable["kills"] = math.min(Variable["kills"] + 1, 3)

Re: Increment on Destroy

Posted: Sat Dec 29, 2018 2:36 pm
by pegassy
That is wonderful. The bodies do not have to vanish anymore to serve the quest! :)