예제 #1
0
파일: Hook.cs 프로젝트: EluardJ/ggj2021
    public void Grab(Transform objectToGrab)
    {
        isHoldingSomething = true;
        isActive           = false;
        grabbedObject      = objectToGrab.gameObject;

        Vector3 contactNormal = (objectToGrab.position - transform.position).normalized;

        transform.rotation = Quaternion.LookRotation(contactNormal);

        objectToGrab.parent = transform;
        Rigidbody otherRB = objectToGrab.GetComponent <Rigidbody>();

        hookRb.mass += otherRB.mass;
        grabbedMass  = otherRB.mass;
        Destroy(objectToGrab.GetComponent <Obi.ObiRigidbody>());
        Destroy(otherRB);
        objectToGrab.GetComponent <Collider>().material = draggedObjectMaterial;

        grabParticles.Play();

        grapple.Grab(objectToGrab.GetComponent <Movable>());;
    }