- Home /
 
 
               Question by 
               kconwaykyle · Oct 31, 2012 at 01:14 PM · 
                meshrendererfalse  
              
 
              MeshRenderer Scirpt help
hello, I was hoping one of you could write me a small script for JavaScript that will cause a invisible object to appear when stepping in a trigger and then disappear a few seconds later.
2..
function OnTrigger
meshRenderer.enabled = false
is the only script i can think of and im pretty sure that wont work
               Comment
              
 
               
              just use Invoke() to make it appear agin
full explanation at unityGE$$anonymous$$S.com
Answer by Montraydavis · Oct 31, 2012 at 02:50 PM
 Object 1: whatever.js
 function OnTriggerEnter ( )
 {
    vat objactivate : GameObject = GameObject.Find("Object2"); // Find Object2
    objactivate.active = true ; // Make it appear
    var disScript : DisappearScript = GameObject.Find("Object2").GetComponent ( DisappearScript ) ; // Get Disappear Script
    disScript.CounterActive = true ; // Set Disappear Script.active = true
 }
 
 object 2: DisappearScript.js
 static var CounterActive : boolean = false ; // Active ?
 var counterTime : float = 10 ; // 10 seconds
 
 function Update ( ){
    if ( CounterActive ){// If active
       if ( Mathf.Ceil ( counterTime ) > 0 )// If time hasn't run out
       {
          counterTime -= 1 * Time.deltaTime ; // Minus a second
       }else{// If time run out
          gameObject.active = false ; // Disappear 
       }
    }else{ counterTime = 10 ; } // Reset if not active
 }
 
              Your answer
 
             Follow this Question
Related Questions
White artifacting bordering mesh triangles 0 Answers
renderer cannot enabled .. 0 Answers
White line appearing in an all mesh level? 1 Answer
Ignore/Destroy then re-enable Mesh Colliders 3 Answers
Mesh/Model Problem 0 Answers