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 calyston000 · Apr 23, 2011 at 06:08 PM · coroutineifblinking

Problem with blinking!!! Argh

Help!! Argh i'm doing the Walker Boys Lab (mega-nice tutorials by the way, Kudos, to them for that!) But I'm doing the the first lab! And the sphere blinking is driving me crazy!!!

Here is the problem : I'm starting the routine and I got a swicht that toggle on and off depending if it's need to blink or not. But the problem is that this swicth whenever i put it its never swicth back to false! Hope you can help me!

Here is the code :

//Enemy Script</p> <pre><code>//Inspector Variables var shapeColor:Color[]; var numberOfClick:int = 1; var explosion : Transform; var enemyPoint:int = 1; var respawnTime:float; var BlinkToggle:boolean=false; //private Variables private var storeClicks:int = 0; private var rotateSpeed:int=50; function Start() { respawnTime = Random.Range(1.0, 5.0); storeClicks = numberOfClick; var startPosition = Vector3(Random.Range(-6,6), Random.Range(4,-4), 0); transform.position = startPosition; RandomColor(); } function Update () { RotateMe(); if(numberOfClick &lt;= 0) { BlinkingCoroutine(); if(BlinkToggle==true) { BlinkToggle=false; if(explosion) { Instantiate(explosion, transform.position, transform.rotation); } if(audio.clip) { audio.Play(); } var position = Vector3(Random.Range(-6,6), Random.Range(4,-4), 0); RespawnWaitTime(); transform.position = position; numberOfClick = storeClicks; } } } //Change the respawn time function RespawnWaitTime() { renderer.enabled = false; RandomColor(); yield WaitForSeconds(respawnTime); renderer.enabled = true; } //Change the color of Mat when respawning function RandomColor() { if(shapeColor.length &gt; 0) { var newColor = Random.Range(0, shapeColor.length); renderer.material.color = shapeColor[newColor]; } else { print("You've have to set the color array in the inspector"); } } function RotateMe() { transform.RotateAround(Vector3.zero, Vector3(0,0,1), rotateSpeed * Time.deltaTime); } function Blinking() //Do the blinking by turning it on and off; { renderer.enabled = !renderer.enabled; } function EvokeBlinking() //Evoke the Blinking Command each 0.3 sec for 1 sec. { InvokeRepeating("Blinking", 1, .3); } function BlinkingCoroutine() //Start the calling of the coroutine. Call the blinking for 3 sec, then cancel the invoke and turn back the renderer. { EvokeBlinking(); yield WaitForSeconds(3); CancelInvoke("Blinking"); renderer.enabled=true; BlinkToggle=true; }

Comment
Add comment · Show 2
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 burgunfaust · Apr 24, 2011 at 01:14 PM 0
Share

If you put this on an object in an empty scene, it rotates. If you set the number of clicks variable to a negative number it blinks. BlinkToggle doesn't seem to have any effect on that. It does have an effect on the actual blink code. What is number of clicks used for in the script?

avatar image calyston000 · Apr 24, 2011 at 02:16 PM 0
Share

Just one click before it got destroy! That what bugger me! The sphere is rotating and if you click on it I got a raycast function in the player script that kill the sphere and the blinking should happen!

0 Replies

· Add your reply
  • Sort: 

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

No one has followed this question yet.

Related Questions

If statement inside Coroutine firing without meeting the conditions 2 Answers

Blinking & resource consumption 1 Answer

How do I use Yield in C#? 3 Answers

Animation Event issue what am I doing wrong here 2 Answers

Activating 3 rotations based on multiple presses on one key 2 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