Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Kfinn on July 25, 2014, 07:25:48 PM
-
Hi all.
Not sure how stupid this question is but as a non-coder, I can't figure out how to get Playmaker and NGUI to play together to create a solution to what I need. The NGUI slider defaults to 0 to 1 as the first and last values. I simply want the slider to go from 0 to a bigger number, say 120. Each time I move the slider I'd like the number to increment or decrement by 1, not some tiny fraction. I thought this would be easy with playmaker actions tied to the output of the NGUI slider but I can't seem to figure it out. Any ideas? Thanks!!!
-
NGUI slider goes from 0 to 1... this is NGUI framework.
so in order to get 120 as you want it, you would have to divide 1/120= 0.0083 would be one %.
lets make it 100 for sake of simplicity. you would use float variables. so if you wanted health to be on 5%, you would put in value 0.05, if you wanted it on 50%, you would put in 0.5
-
Hi,
For this you have a custom action to compute the cross multiplication:
http://hutonggames.com/playmakerforum/index.php?topic=5122.msg24311#msg24311
with lots of threads to read on to learn how to work with it:
http://hutonggames.com/playmakerforum/index.php?topic=7907.msg38271#msg38271
http://hutonggames.com/playmakerforum/index.php?topic=6255.msg30368#msg30368
Bye,
Jean
-
Thx Jean and bizilux! My slider now moves from 0 to 120 (or whatever number I chose). Jean's custom action was a simple solution and had the same result as what I had implemented based on bizilux's advice.
I guess my only issue now is the round-off problem. I need my slider to move in increments of 1 from 0 to 120. When I round the sliderval float up, down or to nearest, the roundoff error makes you periodically skip numbers on the scale. I tried changing the code within NGUI's UIProgressBar so I could have as many steps on the slider as needed. I figured that setting the number of steps = 120 would mean each movement on the slider would be +/- 1. No such luck.
Thanks for any help you can offer!
-
Hi,
Then you need to work from scratch with Ints, don't work with floats.
else, make sure you really maintain floats separated from the actual result you display and the slider value you inject in ngui, create a specific float value that you use to slide virtually, and use another float that you round off for when you inject in the slider itself.
Also, have looked in ngui forum and asked for this? I am sure many ngui users wanted to the same thing.
Bye,
Jean
-
you can try using: convert float to int
and then underneath it, convert int to float
this should solve it