- Home /
Question by
mragent0028 · Nov 01, 2012 at 03:56 PM ·
rendererenabledfalse
renderer.enabled false not working
I am trying to write a code so when I press the E key an object go away as kind of the first step for a weapon pick up. I typed the following code but the error "The referenced script on this behaviour is missing."
function Start () {
}
function Update () {
var tennisPickUp : boolean = false;
if(tennisPickUp) {
renderer.enabled = false;
}
if(Input.GetKeyDown("e"))
{
tennisPickUp = !tennisPickUp; } }
Comment
Answer by Eric5h5 · Nov 01, 2012 at 04:18 PM
You set tennisPickUp to false every frame and then check to see if it's false right afterward, which logically it can never be. Presumably you want to define that variable outside Update. Also please format code when posting it in the future.