playMaker

Author Topic: How do you animate UI Float Amount?  (Read 3276 times)

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
How do you animate UI Float Amount?
« on: February 24, 2022, 08:00:40 PM »
Hey there hoping someone can help with an issue:

I have a UI Image mask that animates vertically from top to bottom, with a fill amount of 1 that needs to go to 0 when the player finishes and completes 100% of the task. Everything is setup including getting the float values etc.

But I'm having a hard time figuring out how to animate the Fill Amount on the UI Image. I've tried Animate Fill Amount, and v2, Animate Float etc...

Which FSM do I use and what settings would I use? I've attached a few screenshots.

Thank you so much.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do you animate UI Float Amount?
« Reply #1 on: February 24, 2022, 09:55:47 PM »
Hi.
you can use a "Ui Image Set Fill Amount" and a Tween Float
on Ui Image Set Fill Amount turn on every frame and set a variable, then use the variable in the tween float

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: How do you animate UI Float Amount?
« Reply #2 on: February 25, 2022, 10:34:41 AM »
Hey thanks for the response.

The only other missing thing though is what FSM do I use to compare the value of the fill amount with my other script that has a percentage from 0-100. So I'm looking to compare and match the fill amount with the percentage.

Player has completed 44%
Fill amount is at 44%

I would probably need a float compare?

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do you animate UI Float Amount?
« Reply #3 on: February 25, 2022, 11:16:35 AM »
divide by 100 to get normalized (0-1)

but code wise it would be better to use a percentage between 0 and 1 (1 = 100% 0.5 50%)
and if you need to display then use *100

there is also an action to Get the filled amount btw

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: How do you animate UI Float Amount?
« Reply #4 on: February 25, 2022, 11:21:03 AM »
I did this before I saw your last message. I'm close....

When the player enters the area and the percentage starts going up, the float amount jumps from 0-100 (where it should be going up matching the percentage). So I'm close...

So as per your comment to divide by, do I need another FSM for that? Check out my screenshot and let me know what you think.  :D

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do you animate UI Float Amount?
« Reply #5 on: February 26, 2022, 11:36:42 AM »
Hi.
You can use a Float Operator and set it Every Frame

so float 1 is 0-100 (variable)
float 2 = 100
and set to 'divide' and every frame enabled
and set a result variable (should be beween 0 and 1)

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: How do you animate UI Float Amount?
« Reply #6 on: February 28, 2022, 12:33:59 PM »
Thank you!! Finally got this working after many hours lol. The image mask fill amount is going backwards but at least it's working. I will figure out how to go in reverse.

Here's what I did in case others want to know how to do this and again thank you for your help I appreciate it.  :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do you animate UI Float Amount?
« Reply #7 on: February 28, 2022, 02:02:51 PM »
Hi.
Try Multiply by -1

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: How do you animate UI Float Amount?
« Reply #8 on: February 28, 2022, 02:49:40 PM »
Hey thanks! I actually just changed the way I had my mask setup.

Cheers.

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: How do you animate UI Float Amount?
« Reply #9 on: March 01, 2022, 05:10:59 PM »
Hey Djaydino, Would you know how to tween the float as it moves? I have DoTween and I'm trying to tween the values as the fill circle mask moves so it's not so choppy. I'm using DoTween Animate Float but nothing I try seems to work. Screenshot attached.

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do you animate UI Float Amount?
« Reply #10 on: March 01, 2022, 09:05:37 PM »
Hi.
Maybe you can use the build in tween float (i'm have not used doTween yet)

It has setting to start from current value

Shizane

  • Junior Playmaker
  • **
  • Posts: 52
Re: How do you animate UI Float Amount?
« Reply #11 on: March 02, 2022, 07:44:41 AM »
Yeah I had tried the built-in Tween before DoTween and couldn't seem to get it to work. But maybe im missing something. Do you need to specify a time as a variable? Ive attached what I have and here's my variables:

storePercentage (stores the current value of the players progression)
circleFillAmount (gets the value of the fill mask)
snowCirclePosition (sets the value of the fill mask)

Also - should it be in Real Time and what should the update type be?

Thank you.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: How do you animate UI Float Amount?
« Reply #12 on: March 02, 2022, 08:37:37 AM »
Hi.
Time is the Tween duration
Real time is for when you use Scale Time (for example when you want to pause the game and set scale time to 0)
If real time is checked its not manipulated by Scale Time.

'From' is where the tween start (curve 0) on that you have different settings (current value/Offset/Value)
'To' is where the tween end (curve 1) on that you have different settings (current value/Offset/Value)

Update time in most cases you want to use fixed update.
To know more about update types its best to google unity update time.

Best is to play around with them so you understand howthey work (on a test scene for example)