"Clamped" number variables?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

"Clamped" number variables?

Post by Abelius »

Hi there,

I was wondering if there's some easy way in DS to declare a number variable with min and max values, just from the interface, so I don't need to resource to external code to clamp its value periodically...

If not, I use PlayMaker so I guess I could make a 'watcher' FSM, but that solution doesn't ring just right, performance-wise, to me (I think).

Thanks.
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

Re: "Clamped" number variables?

Post by Tony Li »

There's no built-in way to automatically clamp to min and max values.

I agree that a 'watcher' FSM wouldn't be the most efficient solution. But then again it might not be an issue if you only check, for example, at the end of conversations.

Depending on how you change the variable's value, you could register a custom Lua function to set a variable with clamping, or do the same with a PlayMaker action.

BTW, if you're using the Increment On Destroy component, it clamps, so you don't need to do anything special for it.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: "Clamped" number variables?

Post by Abelius »

Ok, no problem. I'll go for the 'clamp everything' approach at the end of conversations.

Thanks for your quick response!
Unity 2019.4.9f1
Dialogue System 2.2.15
Post Reply