Hello, so I made a basic script.
var buttonInRange; //Variable if the 'character is in the radius.
public var guiSkin : GUISkin; // Not Really needed for now
function OnTriggerEnter (c : Collider) // If character enters the Collider
{
buttonInRange = true; // If Inside collider make buttonInRange true
}
function OnTriggerExit (c : Collider) // If Character exits the Collider
{
buttonInRange = false; // If exited the collider ButtonInRange false
}
function OnGUI() // Displaying a GUI
{
if(buttonInRange == true) // If you are inside the collider
{
GUI.skin = guiSkin;
GUI.Label(Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Pick up RPG 7"); //Make a text saying Pick Up RPG
}
}
function Start ()
{
}
function Update ()
{
if(buttonInRange == true) // If inside collider
{
if(Input.GetKeyDown ("e")) // If inside collider and pressed 'E'
{
Destroy(gameObject); //Destroy RPG!
}
}
}
So, i’m not a really pro but I’m like a beginner in scripting, so my question is how would I not destroy this Object but make it Attach to my First Person Controller? If so and video would be handy… Thank you for helping already