Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by wenhua · Jan 17, 2012 at 09:58 AM · blinking

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by robert_mathew · Jan 17, 2012 at 10:26 AM

  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  
Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Marnix · Jan 17, 2012 at 10:30 AM 0
Share

This isn't really blinking. But more like, disappearing and returning...

avatar image robert_mathew · Jan 17, 2012 at 10:48 AM 0
Share

i think by blinking he mean to on off the renderer in a particular time

avatar image wenhua · Jan 18, 2012 at 01:07 AM 0
Share

This script will be attach to the sphere itself, simply want it to keep on disappearing and returing. But some how your script is not working, nothings happen, can you check it out thx

avatar image robert_mathew · Jan 18, 2012 at 04:12 AM 0
Share

i have edited the script attach the script to the sphere you want it to appear and disappear and var ball : GameObject assign the sphere to var ball to the script which you want to make appear and disappear it will work i have tested the script it is working

avatar image wenhua · Jan 18, 2012 at 08:56 AM 0
Share

yea Thx alot it works

Show more comments
avatar image
4

Answer by ByteSheep · Jan 18, 2012 at 03:53 AM

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 :)

 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;
   }
 
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image wenhua · Jan 18, 2012 at 08:55 AM 0
Share

your script works. Its for Render.color. Below is now a fine script where is blink for whole gameObjects. Nicer Thx anyway

avatar image wenhua · Jan 27, 2012 at 01:18 AM 0
Share

hi merry_chirstmas i need help in you in audio sound, if you know about it, please take a look on my question (my second audio not working. Thx

avatar image
1

Answer by Marnix · Jan 17, 2012 at 10:29 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image wenhua · Jan 18, 2012 at 01:20 AM 0
Share

$$anonymous$$arnix renderer.material.color = Color.red are able to display red. So how am i going to make it auto keep on disappearing and returing, any idea i have somethings see if it is useful but i just dunno how to add it on gameobject.a = $$anonymous$$athf.Sin(Time.time * 8.0);

avatar image
0

Answer by gingerben93 · Oct 07, 2017 at 02:25 PM

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);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

indestructible gameobject 0 Answers

How can I blink a gameobject faster and faster? 1 Answer

Trying to make a renderer blink on and off, it's not working but I get no errors when building? 1 Answer

GUI text blinking opacity 1 Answer

Why are my 2D sprite GameObjects blinking and how do I fix this problem? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges