- Home /
Question by
PegasiStudios · Dec 24, 2014 at 12:05 PM ·
javascriptfunctionrendereroncollisionenteronlevelwasloaded
how to make object stay destroyed after OnTriggerEnter?
im making a zelda 1 fps game, and you start on the outside. i went into the cave in front of me and the sword i put there isnt supposed to be invisible until i get it. what can i do to fix it?
heres the js code i put:
pragma strict
function OnLevelWasLoaded() { if ( renderer.enabled == true ) { renderer.enabled = false; } }
Comment
Answer by SkaredCreations · Dec 24, 2014 at 12:10 PM
You could use for example PlayerPrefs to set a variable to check if the player already picked up the sword, if he already picked you should destroy the sword. But I would slightly change the logic, that is it should not spawn everything and then destroy, but instead the spawn of this sword should be done in code and only if the player didn't already pick it.