I trying to make a object invisible on start and when collision happened it will appear. So I decide to disable the sprite renderer. But when I click play the object is still visible.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pg10_dropSeed : MonoBehaviour
{
private SpriteRenderer seedRender;
void Start()
{
seedRender = GetComponent<SpriteRenderer>();
seedRender.enabled = false;
}
}
I am working on a similar feature!
You may try moving “seedRender.enabled = false” after void Update (); below please find my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpriteReaction : MonoBehaviour
{
SpriteRenderer rend;
// Start is called before the first frame update
void Start()
{
rend = GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void Update()
{
this.rend.enabled = false;
}
}
Otherwise, have you add the script to the object, and, if you have seen the box for “Sprite Renderer” unchecked when the game starts?