How do i make a 2D game object transparent?

Im trying to make a game object in my game go semi transparent when it touches another game object. I’ve got the bit working where the tag changes and it cant collide with a certain object (because the code makes it “invisible”). but i just cant manage to figure out how to change the transparency.

Can anyone please help?

You can get a hold of it’s SpriteRenderer component (with Get/TryGetComponent) and then change its colour: Unity - Scripting API: SpriteRenderer.color

Namely by reducing the alpha of its colour.

1 Like