- Home /
Why my object not disappear?
Hello :)
I have code like this:
void Update () {
//move element
myTransform.Translate (Vector3.up * projectileSpeed * Time.deltaTime);
//if hit something
if (Physics.Raycast(myTransform.position, myTransform.up, out hit, range) &&
expended == false) {
//if hit floor
if(hit.transform.tag == "Floor"){
expended = true;
myTransform.renderer.enabled = false;
myTransform.light.enabled = false;
**Debug.Log(myTransform.renderer.enabled);**
}
}
}
i use debug.log and i know that the if statment was executed but i still can see the object why?
Well, what's the outcome of the second Debug.Log? false? If so, run the game, press pause the moment you receive the message and see which renderer was actually disabled.
Answer by giulio-pierucci · Feb 13, 2015 at 11:24 PM
Add Debug.break after debug.log. The game will pause.
After this, do some test:
if you click projectile, renderer is checked in inspector?
If you check/uncheck manually from inspector, object disappear?
Maybe that there are 2 renderers/gameobjects?
There are another script that set projectile renderer enabled?
Your answer
![](https://koobas.hobune.stream/wayback/20220613183222im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
External Libraries in C# scripts 1 Answer
Animation Input / ETC 1 Answer