objets de ramassage et de dépression d'unité

I have no javascript version, but you can use something very simple like this in C#:

TakeMe.cs:

 using UnityEngine;
 using System.Collections;
 
 public class TakeMe : MonoBehaviour {
     
     private Transform taker;
     
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
             
         if(Input.GetKeyDown("t")) {
 
             transform.parent = taker;
             
         } else if(Input.GetKeyDown("g")) {
 
             transform.parent = null;
             
         }
 
     }
     
     void OnTriggerEnter (Collider col) {
         
         if(col.CompareTag("Player")) {
             
             taker = col.transform;
 
         }
         
     }    
         
     void OnTriggerExit (Collider col) {
 
         if(col.CompareTag("Player")) {
             taker = null;
         }
     
     }
 }
moi_crn