Hey guys. I’m trying to make an animated character appear and play his animation when the player walks through a trigger. I have the Java script to make the character start the animation and play a sound, but I can’t figure out how to make the character invisible and then render when the trigger is activated.
I’m a super noob at coding I must mention.
But that’s for turning something off? I want it to start off then turn on. I’m not quite sure what to do with that line of code.
in start() you can initially make the object “invisible” by this
void Start()
{
theCharacter.SetActive(false); //Make it invisible
}
Then when the player enters the trigger,
simply call
theCharacter.SetActive(true); //Show the item
Or disable the renderer component in the inspector. Then, in the OnTriggerEnter code use
GetComponent<Renderer>().enabled = true;
to turn it back on at runtime.
So I tried both of those and i’m not sure what i’m doing wrong. Both times it says there is script errors.
On the GetComponent().enabled=true; script I put it on the same one as my ONTriggerEnter and it gave me these errors.