Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Alatriste on December 26, 2015, 06:30:57 AM

Title: [SOLVED] Clamp int
Post by: Alatriste on December 26, 2015, 06:30:57 AM
Hi, I've never used this action before and I'm a bit confused about how to use it correctly.

In my scene, I'm using the "int clamp" order to specify the value of an int value to a min. of 0. However, later on I adding/substracting int values (in a range of 10) to that variable, but when it should stop at 0, it continues with -10.

Has to run the int Clamp order all the time while I'm doing operations with that variable, or the order is declared once and that's it?

Any help?
Title: Re: Clamp int
Post by: djaydino on December 27, 2015, 11:18:12 AM
Hi,
The clam int should be in a active fsm state.
I am on my cellphone atm so i can not check this....

Make a new fsm anfd set in the start state the clamp int action.
If there is a checkbox "every frame" check it and try if that works.
Title: Re: Clamp int
Post by: Alatriste on December 27, 2015, 12:03:21 PM
Hi Djaydino, I did as you said but didn't work, running the action everyframe. The int clamp is between 0 and 100 and still goes to -10 when I substract.
Title: Re: Clamp int
Post by: djaydino on December 29, 2015, 02:03:36 AM
Hi,
it should work, try this sample :

fsm 1 is clamping the int and displaying it in the game,
fsm 2 is deducting from the int value

if you stil can't get it to work, can you show some pictures or even better, can you show a video with the actions involved.

(http://s25.postimg.org/5c2rkz5hr/Untitled_1.jpg) (http://postimage.org/)
Title: Re: Clamp int
Post by: Alatriste on December 30, 2015, 03:29:53 AM
Thanks a lot djaydino.
I will give a few tries and if it doesn't work I will record a video so we can look at what I'm doing wrong. (it would be next week anyway, as now I'm in my laptop and I don't have the recording software)
Title: Re: Clamp int
Post by: Alatriste on December 30, 2015, 06:36:38 AM
Ok, I managed to make it work following your visual examples. I think the error was in the way I was handeling the variable. The int was working but because I didn't update every frame the result of the int converted to string var, the outcome was negative. I managed to make it work adding all the convert int to string and building the string for the text in the same state. That way it worked.

Thanks a lot djaydino!