hey guys, i’ve been trying to make an object dissapear when i take it but this code doesnt work:
var Target : Transform;
var rayHit : RaycastHit;
var ShowInsp = false;
var DistanceA = 10;
var S1 : Vector2 = Vector2(380,460);
var S2 = 120;
var S3 = 20;
var B1: Vector2 = Vector2(670,500);
var B2 = 500;
var B3 = 70;
var P1 : Vector2 = Vector2 (590,460);
var P2 = 120;
var P3 = 20;
var LargePot = Transform;
var Info = "This potion is larger than the other. You try to open it but your hands can't grip it right.";
function Update () {
}
function OnMouseOver () {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Input.GetMouseButtonDown(0) Physics.Raycast(ray, rayHit, DistanceA) GlobalInsp.TakenPot == false) {
Target =rayHit.transform;
ShowInsp = true;
}
}
function OnGUI () {
if(ShowInsp) {
GUI.Box(Rect(Screen.width - B1.x, Screen.height - B1.y, B2,B3), Info);
if(GUI.Button(Rect(Screen.width - P1.x, Screen.height - P1.y, P2, P3), "Take")) {
TakePot = true;
OnTakePot ();
ShowInsp = false;
}
if(GUI.Button(Rect(Screen.width - S1.x, Screen.height - S1.y, S2, S3), "Leave")) {
ShowInsp = false;
}
}
}
function OnTakePot () {
GetComponent(LargePot).enabled = false;
}
ofcourse the following is the key parts:
var LargePot = Transform;
function OnTakePot () {
GetComponent(LargePot).enabled = false;
}
my error:
MissingFieldExecption: Field “unityEngine.Transform.enabled” not found