Very simple picking up items script?

Hi! I have a flashlight laying on the ground and I want it to be so when the player collides with it, they will be able to use the flashlight.

I tried to look up the answer for myself, but all the answers I could find involved complicated inventory scripts and gui’s and stuff. I just want a very simple way to pick up and use a flashlight. Thanks for any advice :slight_smile:

use trigger functions on the item. for example

    function OnTriggerEnter(other : Collider){
    if(other.gameObject.name == "Player"){
    transform.parent = PlayersHand.transform;
    transform.position = PlayersHand.transform.position;
     }}

You need to a box collider set to trigger on the flashlight or any object

Try this :

//This is the script for the player
var Visible : boolean = false;
var light : Light; 
var FlashLight : GameObject;



function Update () {

if(Visible == true){

   light.enabled = true;
   FlashLight.enabled = true;  


   }
}


//This is the script for the flashlight

var otherScript : <player_script_name_here>;

function OnTriggerEnter (other : Collider){


 if(other.gameObject.tag == "Player"){
  otherScript.Visible = true;




    }

}