On trigger, enable renderer.

Hi.

So I’m working on a game and I can’t put videos for a cutscene so I thought I would just go for some basic texts.

Now, I made a text visible and the other one is not visible from the script, I also added a OnTriggerFunction which basically says “If Sphere hits the text’s collider, enable renderer”.

Here is my code.

using UnityEngine;
using System.Collections;

public class Cutscene : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		renderer.enabled = false;
	
	}

	void OnTriggerEnter (Collider SphereCollider) {

		if(SphereCollider.gameObject.CompareTag("SSphere")){
			renderer.enabled = enabled;
		}
	}
}

I added the tag “SSphere” and created colliders for the objects, added rigidbody too but it won’t make the renderer visible on trigger, why?

instead of

renderer.enabled = enabled;

you probably want

renderer.enabled = true;

although you probably don’t want to be setting it to false in Update() - perhaps Awake() or Start()