Can anyone tell me what is the best way to do effect on 2.22?
I am trying to mark an area with red color and once it finishes, player who stands in it will take damage.
Does making PNGs in photoshop and make it animation works or there is a way to change a red color cube’s opacity in unity?
if you’re talking about the red flashing by itself what you could do is simply put a red plane in front of the camera ( Make sure to cover the viewport entirely ) and make the plane a child of the camera, set the alpha colour to 0 and then keyframe the alpha colour to an animation clip and have that animation play when your character runs into an invisible trigger collider of some sort.
SpriteRenderer.color = new Color(1f,1f,1f,1f) is a normal sprite
SpriteRenderer.color = new Color(1f,1f,1f,.5f) is about 50% transparent
SpriteRenderer.color = new Color(1f,1f,1f,0f) is about 100% transparent (Cant be seen at all, but still active)
to change the opacity.
Do u think its a good idea to use a loop
while (condition)
SpriteRenderer.color = new Color(1f,1f,1f,.5f);
yield WaitForSeconds(0);
SpriteRenderer.color = new Color(1f,1f,1f,.1f)
yield WaitForSeconds(0);
That’s a bit of an advanced question for me as I don’t have that much knowledge on the engine, but if it works go for it, I’m not sure if a while loop takes up more resources than an animation but since you only have the one plane it should be fine either way I would imagine.
I would stick with the animation method if you’re having trouble, I think that’s simpler which is why I suggested it, it looks to me like that’s the beginnings of an iEnumerator and that’s far too complicated for the effect you want to achieve.
What I’ve done for a fade in/out to black effect, but would be similar here, is to just have a UI texture stretched across the screen and just adjust a Canvas Group’s opacity value in update or a coroutine.