- Home /
Making object "Blink"
Hello,
I have a coin object that disappears after several seconds of hitting a ground. What I was thinking of doing was making it slowing "blink," eventually blinking rapidly then disappearing.
Now, by "blink," I mean making it disappear for 0.2f seconds then making it appear again. I am planning on implementing this via Coroutine, but I was wondering if it is not too costly to make a coin disappear by doing (renderer.enabled = false) then doing (renderer.enabled = true) this often in a short span of time. There could be up to 10~20 coins in the scene at the same time, all blinking at its own rate.
I feel like since this is not the most unique way of indicating that something is about to disappear in games, there must be some standard way of doing this.
So yeah - is this the most efficient way of doing this?
I'm not sure which is more efficient, but some other solutions I can think of off the top of my head:
move the coin onscreen and off screen positions
Scale the object to zero and back to original size
Note, I'm not saying lerp. $$anonymous$$ake the changes instantaneous and both will give you simulated blinking effect.
Try with setActive(true / false) (or) $$anonymous$$ake Gameobject enabled true/false with in invoke repeating. when you want to stop cancel the invoke :)
Answer by fafase · Jul 03, 2014 at 02:46 PM
enable/disable is just a boolean switch, pretty much nothing.
I would think when rendering step comes in, Unity first check for that value to discard or process further the rendering.
It is nothing even for 20 coins and 2 times per second.