playMaker

Author Topic: How to Fade a Gameobject In and Out?[SOLVED]  (Read 6717 times)

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
How to Fade a Gameobject In and Out?[SOLVED]
« on: August 06, 2014, 02:10:42 PM »
Hi,
I want to fade a gameobject (a 2dtoolkit sprite to be specific) in and then out. I don't believe that there is such an action in playmaker. I found this action which seems to achieve what I want though: http://hutonggames.com/playmakerforum/index.php?topic=1777.0, but I am not quite sure how to use it! :P

If someone could guide me through the process of making a simple FSM with this or a similar action to fade in and out a sprite that would be great! (a 2dtk sprite preferably but I don't think that it would make a difference).

Thanks
« Last Edit: March 30, 2016, 04:37:36 AM by jeanfabre »

cmonroy

  • Playmaker Newbie
  • *
  • Posts: 34
Re: How to Fade a Gameobject In and Out?
« Reply #1 on: August 09, 2014, 10:52:33 AM »
You also have a Camera Fade In and Camera Fade Out actions... Both actions only requiere a time value and have a finishing event.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: How to Fade a Gameobject In and Out?
« Reply #2 on: August 09, 2014, 12:53:29 PM »
Have you tried the Sprite Set Color action in the 2D Toolkit actions:
https://hutonggames.fogbugz.com/?W717

Use the alpha component of the color to control transparency.
Use Ease Color (or another tweening action) to change the color over time:
https://hutonggames.fogbugz.com/default.asp?W566

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
Re: How to Fade a Gameobject In and Out?
« Reply #3 on: August 10, 2014, 11:12:12 AM »
Hi,
Thanks for your reply. When I use the ease color or the sprite set color action nothing happens. I know that I am doing something wrong, but I'm not quite sure what! How would you accomplish a fade in/out with the sprite set color actions or the ease color actions (also would you use both or only one)? Obviously my method isn't working!

I am also getting this error when I try to run it:
Code: [Select]
OpenGL Context became invalid during rendering

Thanks


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Fade a Gameobject In and Out?
« Reply #4 on: August 18, 2014, 04:32:43 AM »
Hi,

 What shader do you have on your sprite material? and what platform do you target?

 Your errores happens in Unity or at runtime?

 Bye,

 Jean

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
Re: How to Fade a Gameobject In and Out?
« Reply #5 on: August 18, 2014, 06:59:07 AM »
The sprite material uses the default tk2d/"BlendVertexColor" shader. I also get this error
Code: [Select]
NullReferenceException: (null)
UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs)
UnityEditor.Editor.GetSerializedObjectInternal ()
UnityEditor.Editor.get_serializedObject ()
UnityEditor.MaterialEditor.OnEnable ()

However, this hasn't seemed to cause any issues for me and I think that it is a tk2d error. I am targeting the iOS platforms and, if I remember correctly, the error occurs at runtime. It may just not work since I have set up my FSM incorrectly, but I still can't figure out the correct way to get the FSM to work.

Any help on this would be appreciated :)
Thanks!

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
Re: How to Fade a Gameobject In and Out?
« Reply #6 on: August 22, 2014, 08:39:30 AM »
Bump

KellyRay

  • Full Member
  • ***
  • Posts: 170
Re: How to Fade a Gameobject In and Out?
« Reply #7 on: August 22, 2014, 09:56:23 AM »
I've never worked with a 2dtk object but why not use the animator component? Create a new animation on the object you wish to fade out and use keyframes to change the value of the alpha from 255 to 0.

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
Re: How to Fade a Gameobject In and Out?
« Reply #8 on: August 26, 2014, 04:46:24 PM »
I hadn't actually considered that before. I have never actually ended up using the animator in 2dtk. However, I have seen on some topics such as this: http://2dtoolkit.com/forum/index.php?topic=1604.0 that it is much more complicated since you cannot animate properties, and I have little coding experience which is why I would prefer to do it through playmaker. Also, when I try to change the shader it always reverts back to the default tk2d/blendvertexshader.
« Last Edit: August 26, 2014, 04:49:32 PM by blazingriver »

timoe

  • Playmaker Newbie
  • *
  • Posts: 6
Re: How to Fade a Gameobject In and Out?
« Reply #9 on: March 30, 2016, 04:30:30 AM »
Thanks! That works perfectly for my purpose!


Have you tried the Sprite Set Color action in the 2D Toolkit actions:
https://hutonggames.fogbugz.com/?W717

Use the alpha component of the color to control transparency.
Use Ease Color (or another tweening action) to change the color over time:
https://hutonggames.fogbugz.com/default.asp?W566