Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Raknill on September 22, 2016, 02:13:22 AM

Title: Fading in an Alpha Value
Post by: Raknill on September 22, 2016, 02:13:22 AM
Hello everyone. I've been at this (I thought) relatively simple task for a few hours, to no avail.

I'm trying to fade in an alpha value on a GUI element, and I just can't get it to work. I'll walk you through what I'm doing here; I'm hoping to learn what I'm doing wrong here.

First, I'm using the GET Property Function to grab the "color.a" value and store it in a float variable called "Newspaper GUIAlpha"

(http://i.imgur.com/QSqyKeE.jpg)


Then, I'm using the "Float  Interpolate" function to interpolate the value of "Newspaper GUI Alpha" (which is initialized to 0) to 255 over 5 seconds.

(http://i.imgur.com/AM4EfXW.jpg)

This has no effect, though. I have also tried using "Float Animate" to no avail.

Am I using "Get Property" wrong? Thanks in advance for any help; looking forward to expanding my knowledge here.

Title: Re: Fading in an Alpha Value
Post by: djaydino on September 23, 2016, 12:25:02 PM
Hi,
Always try to avoid using get/set properties.

You need to get "ugui proxy full" from the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) (on the Ecosystem you can find lots of custom actions)

to get to alpha value you need to use the action "U Gui Graphic Get Color"
then you need to use "Get Color RGBA" and get the alpha, name it 'old alpha' (for example)
(this should actually be build-in in the "U Gui Graphic Get Color" and i will ask jean if we can change this)

Then on the other state use the "Float Interpolate" and set from float as 'old alpha' (or however you called it) and on the store result use (for example) 'New Alpha'

on the same state add "U Gui Graphic Set Color" and on Alpha use 'New Alpha'
also check every frame.

Here you have some info about the ugui proxy :

Title: Re: Fading in an Alpha Value
Post by: Raknill on September 24, 2016, 11:53:25 PM
I appreciate the detailed support.

Still having an issue, but I must be almost there.

Right now, as soon as the second state is activated, the GUI image just pops right up, still no fade.

You mentioned that in "Graphic Set Color", you should set the Color Alpha to "New Alpha" (in my case, I'm using "Alpha Visible). When doing that though, the alpha is instantly set to 255, rather than running through the interpolation. So instead, I used a third float variable called "Newspaper Alpha Float" that is used in "Graphic Set Color" as well as the stored alpha in "Get Color RGBA".

(http://i.imgur.com/xe9Rd7z.jpg)

So to surmise, my variables are as follows:
Newspaper Alpha (Color Variable).
Alpha Invisible: 0.
Alpha Visible: 255.
Newspaper Alpha Float: 0.


Sorry if I've missed something obvious here; you've been a big help.

EDIT: And to clarify, Newspaper Alpha Float DOES seem to be interpolating correctly, just no fade.
Title: Re: Fading in an Alpha Value
Post by: djaydino on September 25, 2016, 08:16:20 AM
Hi,
I believe that the alpha value goes from 0 to 1, not to 255
i think that is the problem :)
Title: Re: Fading in an Alpha Value
Post by: Raknill on September 25, 2016, 12:52:53 PM
Ha ha, wow, that was it. I have a beautiful fade now; and egg on my face.  :o

Thanks for the help, learning a lot here.

IF you don't mind and have a little time, I have one more small question. You mentioned that it's best to avoid using "Get/Set Property", could I ask why that is? I use it pretty frequently right now, and I just want to know if that's a habit I should nip in the bud early on.
Title: Re: Fading in an Alpha Value
Post by: djaydino on September 25, 2016, 06:24:24 PM
When you make a build from your game they break sometimes (not sure if that is fixed on latest version tho)
Also it needs more coding to do things.
on bigger project it will also become harder to debug when you have a lot "get / set properties"
Title: Re: Fading in an Alpha Value
Post by: Raknill on September 25, 2016, 10:07:55 PM
Gotcha, appreciate the explanation and all the help.

Looking forward to contributing more to this community once I get some more fundamentals down.

Thanks again.