Increment on Destroy

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Increment on Destroy

Post 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.
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: Increment on Destroy

Post 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)
pegassy
Posts: 135
Joined: Sat Mar 17, 2018 8:07 pm

Re: Increment on Destroy

Post by pegassy »

That is wonderful. The bodies do not have to vanish anymore to serve the quest! :)
Post Reply