how to make a sphere/ball blinking

i have create a gameobject(sphere), So any1 know how to make this sphere blinking,please kindly share with me thx alot

i just need simple function like how to make the sphere keep on continue disppearing and returing. Any1 know how to do it. please kindly help me Thx

public GameObject ball; //assign the game object sphere or what ever you want to blink
public double timer;
public bool onoff;

 void Update()
                {
            sphere_blink();
                }

 void sphere_blink()
                  {
	     if (Time.time > timer)
                       {
                  	
  		       timer = Time.time + .4;
   			   onoff = !onoff;
   			   ball.renderer.enabled = onoff;
   			      
   			            }//Time.time > timer ends
   			      
                   }//sphere_blink ends	//in c# call the function  sphere_blink() where ever you want the sphere to blink  

  var ball :  GameObject ; //assign the game object sphere or what ever you want to blink
  var  timer : double ;
  var onoff : boolean  ;

   function Update()
                {
            sphere_blink();
                }

  function sphere_blink()
                    {
	      if (Time.time > timer)
                       {
                  	
  		      timer = Time.time + .4;
   			  onoff = !onoff;
   			  ball.renderer.enabled = onoff;
   			      
   			           }//Time.time > timer ends
   			      
                   }//sphere_blink ends	//in java script call the function  sphere_blink() where ever you want the sphere to blink

This should work fine, as it is now it will change the color of the sphere every half second but you can adjust this by setting WaitTime to a different number :slight_smile:

var timer : float;
var WaitTime : float = 0.5;
var ResetPoint : float;

function Start () {

ResetPoint = WaitTime * 2;

}


function Update () {

timer += Time.deltaTime;

  if(timer < WaitTime)
  {
  renderer.material.color = Color.white;
  }

  if(timer > WaitTime)
  {
  renderer.material.color = Color.red;
  }

  if(timer > ResetPoint)
  {
  timer = 0;
  }

}

You have to access the Renderer component of your ball and change the color of the ball. Depending on what you want, you can change different kinds of colors.

There is the diffuse color (main color), which is the color that reacts on lights.
There is the ambient color, which is the color that doesn’t react at all, but simply lights the object.
And sometimes, there is the specular color, which is the highlight on your object.

In a script, you could make a timer. Whenever the timer goes off, change the color. Then reset the timer and let it count again.

You will need the following components:

http://unity3d.com/support/documentation/ScriptReference/Renderer.html
http://unity3d.com/support/documentation/ScriptReference/Renderer-material.html
http://unity3d.com/support/documentation/ScriptReference/Time.html

Use this.renderer.material.color = Color.red. Or something similar.

A simple way without changing current sprite colors and giving object sprite a fade in and out look would be:

PlayerSprite.color = new Color(PlayerSprite.color.r, PlayerSprite.color.b, PlayerSprite.color.g, (PlayerSprite.color.a + .05f) % 1);