Exemple #1
0
 void ActivateAppropriateAnimations()
 {
     if (rb.velocity.magnitude != 0)
     {
         animator.ActivateAnimation(AnimationType.Walking);
     }
     else
     {
         animator.ActivateAnimation(AnimationType.Idle);
     }
 }
    void PickUpObject()
    {
        Collider col = null;

        if (objectsInRange[objectsInRange.Count - 1].GetComponent <BoxCollider>() != null)
        {
            col = objectsInRange[objectsInRange.Count - 1].GetComponent <BoxCollider>();
        }
        else if (objectsInRange[objectsInRange.Count - 1].GetComponents <SphereCollider>()[1] != null)
        {
            col = objectsInRange[objectsInRange.Count - 1].GetComponents <SphereCollider>()[1];
        }
        else
        {
            return;
        }

        col.enabled                   = false;
        pickedUpRigidbody             = objectsInRange[objectsInRange.Count - 1].gameObject.GetComponent <Rigidbody>();
        pickedUpRigidbody.isKinematic = true;
        pickedUpRigidbody.gameObject.transform.parent        = pickedUpObjectParent;
        pickedUpRigidbody.gameObject.transform.localPosition = Vector3.zero;
        pickedUpObjectType = pickedUpRigidbody.gameObject.GetComponent <PickupableObjects>().ObjectType;

        OnPickUp?.Invoke(pickedUpObjectType);

        playerAnimations.ActivateAnimation(AnimationType.PickingUp);

        FreezePosition freezePos = pickedUpRigidbody.gameObject.GetComponent <FreezePosition>();

        if (freezePos != null)
        {
            freezePos.UnFreezePos();
        }
    }