Hello there, I want to build something like a cave in my platformer game with hidden entry. The player should hit the collider. After the collision, the “cave” should be visible as it is.
My question is now, is there a more simple way to change the transparency of the entire tilemap, because the component “Tilemap” does have a color-option but I can’t access it via script (“Color/color” is not defined for that component). If there is no direct option, would you guess that it is possible with SpriteRenderer>and just put a sprite infront, instead of a tilemap?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TilemapColorChange : MonoBehaviour
{
public KeyCode increase;
public KeyCode decrease;
private Component caveTilemap;
private float transparencyLevel = 0.5f;
void Awake()
{
caveTilemap = GetComponent<Tilemap>();
}
void FixedUpdate()
{
if (Input.GetKeyDown(increase))
{
transparencyLevel += 0.5f;
caveTilemap.SetColor(0,0,0,transparencyLevel);
}
if (Input.GetKeyDown(decrease))
{
transparencyLevel -= 0.5f;
caveTilemap.SetColor(0,0,0,transparencyLevel);
}
}
}
Thank you a very lot in advance