コード例 #1
0
    private void OnTriggerStay(Collider other)
    {
        if (other.GetComponent <objectgrab>() != null) //si l'objet en collision est un Chip
        {
            objectgrab chip = other.GetComponent <objectgrab>();
            chipRb = other.GetComponent <Rigidbody>();

            if (occuped == false && chip.inHand == false) //si le slot n'est pas déjà occupé et que le chipn n'est pas tenu en main
            {
                occuped = true;
                other.transform.position = aimantpoint.transform.position; //snap position
                other.transform.rotation = aimantpoint.transform.rotation; //snap rotation
                chipRb.isKinematic       = true;                           //rend kinemetic (n'a plus besoin de recevoir la physique tant qu'il est attaché)
                // l'objet peut cependant bougé quand le joueur va l'attraper car il est set en tant qu'enfant de la main et déplacé avec le transform et non la
                // physique, bien avoir "parent to hand" dans les attachments flags de "throwable"
            }
        }
    }
コード例 #2
0
    private void OnTriggerStay(Collider other)
    {
        if (other.GetComponent <objectgrab>() != null) //si l'objet en collision est un
        {
            objectgrab chip = other.GetComponent <objectgrab>();
            inter = other.GetComponent <Interactable>();
            rb    = other.GetComponent <Rigidbody>();

            if (occuped == false && chip.inHand == false)
            {
                //inter.attachedToHand.DetachObject(other.gameObject);
                other.transform.position = aimantpoint.transform.position;
                other.transform.rotation = aimantpoint.transform.rotation;
                rb.isKinematic           = true;
                occuped    = true;
                atractdone = other.gameObject;
            }
        }
    }