- Home /
How can I blink a gameobject faster and faster?
Hello Guys! Im making a boss for a 2D spaceship shooter game and the boss's moveset has a move when the boss releases a mine and the mine has a radius and I would like to put a danger sign picture above the radius which blinks faster and faster as the time running out and the mine blows up. I hope you can understand guys what I would like to do. Thank you for your help!
You will want the danger image to flash for X seconds and then another timer for the time till the next flash.
Probably use an IEnumerator, then you can do while loop to make sure that the current time has not reached the time yet. Then you can use yield return new WaitForSeconds(timeTillNextFlashSeconds) and reduce this time each iteration., while the overall timer does not change.
Answer by notenlishbutcomingfromottoman · Mar 19, 2020 at 07:41 PM
try something like:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class just_to_try : MonoBehaviour
{
public int ShorteningTime;
MeshRenderer rndr;
bool bossSpecialAttack ;
public int time=x;
// The materials that you will use:white and the normal warning sign
public Material white;
public Material warningSign;
void Start ()
{
rndr=GetComponent<MeshRenderer>();
}
void Update()
{
if(bossSpecialAttack==true)
{
rndr.Material=white;
WaitForSeconds(x);
x=x-ShorteningTime;
rndr.Material=warningSign;
WaitForSeconds(x);
x=x-ShorteningTime;
//use loops for shorter code, I couldn't write it becuse I don't know how to .
}
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Using the timer as a condition 0 Answers
I make a cooldown system. But when cooldown is over my skill is still working. How can i fix that? 0 Answers
Formats of High Score 1 Answer
Distribute terrain in zones 3 Answers