Hello,
The modified script… The GUI window is still not popping up even after the function OnGUI asks it to. Any help would be appreciated!!!
enum PickupType { Health = 0, FuelCell = 1 }
var pickupType = PickupType.FuelCell;
var amount = 1;
var sound : AudioClip;
var soundVolume : float = 2.0;
//var exchange = int; //added from the AIplayerscript
var trigger1 : boolean = false; //added from the forum
//var theGui : GuiScript
private var used = false;
private var mover : DroppableMover;
function Start ()
{
// do we exist in the level or are we instantiated by an enemy dying?
mover = GetComponent(DroppableMover);
}
function ApplyPickup (playerStatus : ThirdPersonStatus)
{
// A switch…case statement may seem overkill for this, but it makes adding new pickup types trivial.
switch (pickupType)
{
case PickupType.Health:
playerStatus.AddHealth(amount);
break;
case PickupType.FuelCell:
playerStatus.FoundItem(amount);
break;
}
return true;
}
function OnGUI(){
if (trigger1){
GUILayout.Label( “Use pineapples to repair your car” );
//GUI.Label(Rect(0,0,50,50), “Hello”,“”);
}
}
function OnTriggerEnter (col : Collider) {
if(mover mover.enabled) {
trigger1 = true;
}
var playerStatus : ThirdPersonStatus = col.GetComponent(ThirdPersonStatus);
//* Make sure we are running into a player
//* prevent picking up the trigger twice, because destruction
// might be delayed until the animation has finished
if (used || playerStatus == null)
return;
if (!ApplyPickup (playerStatus))
return;
used = true;
// Play sound
// if (sound)
// AudioSource.PlayClipAtPoint(sound, transform.position, soundVolume);
// If there is an animation attached.
// Play it.
// if (animation animation.clip)
// {
// animation.Play();
// Destroy(gameObject, animation.clip.length);
// }
// else
// {
// Destroy(gameObject);
// }
//}
// Auto setup the pickup
//function Reset ()
//{
// if (collider == null)
// gameObject.AddComponent(BoxCollider);
// collider.isTrigger = true;
}
//@script RequireComponent(SphereCollider)
//@script AddComponentMenu(“Third Person Props/Pickup”)