So this is what I have:
GetComponent(MeshRenderer).enabled = false;
I got this from another question, but the rest of my script is Java and I was wondering if anyone knows a way to do this in Java rather than c#
basically, I have a box of matches, which I collect and after I collect it, what’s SUPPOSED to happen is a note pops up on the screen when I get near the fireplace, telling me to use my matches. I then press “e” and voila, a fire appears…
Here is my script:
#pragma strict
var buttonInRange;
var buttonActivated;
var batterySound : AudioClip;
var Transparent : Material;
var Matches : GameObject;
var Fire : GameObject;
private var hasPlayed = false;
function Start ()
{
//THIS IS WHERE I NEED HELP
GetComponent(MeshRenderer).enabled = false;
}
function OnTriggerEnter (c : Collider)
{
buttonInRange = true;
}
function OnTriggerExit (c : Collider)
{
buttonInRange = false;
}
if (buttonInRange == true)
{
if (Matches == false)
{
GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Use matches");
}
}
}
function Update ()
{
if (buttonInRange == true)
{
if (Input.GetKeyDown ("e"))
{
AudioSource.PlayClipAtPoint(batterySound, transform.position);
//I ALSO NEED HELP HERE
GetComponent(MeshRenderer).enabled = false;
}
}
}
The problem I’m having is I can’t make the fire start off invsible when the scene loads and become visible when I click “e” and have collected my matches.
If it helps, here is my match script:
var buttonInRange;
var buttonActivated;
var batterySound : AudioClip;
private var hasPlayed = false;
function OnTriggerEnter (c : Collider)
{
buttonInRange = true;
}
function OnTriggerExit (c : Collider)
{
buttonInRange = false;
}
function OnGUI ()
{
if(buttonInRange == true)
{
GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Pick up matches");
}
}
function Update ()
{
if (buttonInRange == true)
{
if (Input.GetKeyDown ("e"))
{
if(!hasPlayed)
{
AudioSource.PlayClipAtPoint(batterySound, transform.position);
Destroy(gameObject);
hasPlayed = true;
}
}
}
}
Any help is much, much appreciated