playMaker

Author Topic: [solved] Gameobject fade out/in  (Read 4124 times)

createasaurus

  • Full Member
  • ***
  • Posts: 146
[solved] Gameobject fade out/in
« on: November 17, 2014, 07:26:21 AM »
I've been reading many solutions to (Gameobject fade out/in) in the forum archives.  But, none have worked for me, or I did not understand how to implement them correctly.

My object description:  It is a 3d object, a simple plane.  (Attached images below) I am using it as a HUD element.  It has an Unlit Transparent Cutout shader.
I am not using a 2d framework in my project - like ngui or 2dtk.

Basically, I'd like it to FadeIn on level load, then FadeOut when a button is pressed.

----------------------------------
I could not figure out how to do this:
Quote
Hi,

 yes, there is kind of. It's a bit involving tho.

basically,

1: you need to have a transparent material applied to it, so if you have a diffuse, switch to "transparent diffuse" so that you can control the alpha channel.

2: have the color in a FsmColor variable, and animate the alpha channel to fade in or out.

3: use the action "Set material Color", https://hutonggames.fogbugz.com/default.asp?W380  and plug this Fsmcolor you are animating.

 If you need a working example, let me know.

 Bye,

 Jean
----------------------------------
I tried Itween FadeTo FadeFrom, but it has problems.  #1) it drops my frame rate significantly, even in the simplest of scenes.  #2) it is not compatible with an Unlit Transparent shader - so I have to use diffuse with a dedicated light to brighten it to match the other Unlit elements.
« Last Edit: November 18, 2014, 06:22:22 AM by createasaurus »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Gameobject fade out/in
« Reply #1 on: November 17, 2014, 09:01:37 AM »
You can't really 'fade in a gameobject' technically. GameObjects either exist or they dont so if you want to make it look like an object fades in you have to change its transparency amount.

That's normally done by changing the Alpha (transparency) channel on a material. Colors have an Alpha property. RGBA stands for Red/Blue/Green/Alpha, check the sliders out when you click a color. A shader may not use the Alpha setting, so make sure you make any necessary changes in the Shader to ensure it uses it.

You can use Set Material Color to change the Alpha on a color, but I'm not sure how to animate the value yet.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Gameobject fade out/in
« Reply #2 on: November 17, 2014, 11:30:02 AM »
Hi Lane,  Thank you.  I'm experimenting based on your ideas.

In my experiments I'm using Set Material Color to change Alpha.  I'm faking animation by manually set a string of states, each giving about a 5% drop in Alpha.  The Unlit Transparent Cutout doesn't seem to work with this, so I'm faking by using a diffuse with a dedicated light to give full color saturation.  This all works good, and it avoids the frame drop issues of using ItweenFadeto.

Thank you again.
« Last Edit: November 18, 2014, 06:22:07 AM by createasaurus »