How to add and subtract a float based on conversational choices?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Digital Adam
Posts: 7
Joined: Fri Nov 01, 2024 2:56 pm

How to add and subtract a float based on conversational choices?

Post by Digital Adam »

Hey. So I have a full conversation ready to go. I need to change a float parameter by a certain amount on a script that's on my character. That float controls blend shapes on my character to show anger, happiness, sadness, etc., from -100 to 100. At -100 the character is angry, 0 she's indifferent (no blend shapes), at 100 she's happy. That I have all set up already. One float parameter on that script from -100 to 100 adjusts the blend shape emotions.

When the conversation starts that outside float is at 0. Depending on the players responses, that float can fluctuate. If the player say something hurtful, I'd like to deduct 20 points for example, making that float a -20, which in turn updates the outside script for the emotional blend shapes.

Is it possible to change a float within Dialogue System per conversational node, and then tell an outside script that number?

Thanks!
Digital Adam
Posts: 7
Joined: Fri Nov 01, 2024 2:56 pm

Re: How to add and subtract a float based on conversational choices?

Post by Digital Adam »

I think I was able to add / subtract variables. Under the Variables tab, I created a Number and called the variable Emotion. The initial value was set to 0. Then on the chosen conversation reply I used this: Variable["Emotion"] = -20 to change the 0 to a -20.

I don't think it adds or subtracts though, just changes the variable to whatever I chose.
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to add and subtract a float based on conversational choices?

Post by Tony Li »

Hi,

To subtract 20 from a Dialogue System variable called Variable["Emotion"], use:

Code: Select all

Variable["Emotion"] = Variable["Emotion"] - 20
If your variable is a Playmaker FSM variable, use the SubtractFsmFloat() Lua function instead.
Post Reply