Beispiel #1
0
    protected override LimbProfile SetLimbProfile()
    {
        LimbProfile prof = new LimbProfile();

        prof.pAnimationRate = 1f;
        prof.pJointSpring   = 1f;
        prof.pAppliedForce  = 0.75f;

        return(prof);
    }
Beispiel #2
0
    void Start()
    {
        mySkeleton = GetComponentInParent <Skeleton>();

        limbRb = GetComponent <Rigidbody>();
        lastRigidbodyPosition = limbRb.position;

        limbJoint    = GetComponent <ConfigurableJoint>();
        limbCollider = GetComponent <Collider>();

        if (limbJoint)
        {
            Vector3 forward = Vector3.Cross(limbJoint.axis, limbJoint.secondaryAxis);
            Vector3 up      = limbJoint.secondaryAxis;
            localToJointSpace  = Quaternion.LookRotation(forward, up);
            startLocalRotation = transform.localRotation * localToJointSpace;
            jointDrive         = limbJoint.slerpDrive;
        }

        //if (transform.localPosition.x < 0f)
        rigidbodyPosToCOM = Quaternion.Inverse(transform.rotation) * (limbRb.worldCenterOfMass - transform.position);
        // else
        //   rigidbodyPosToCOM = Quaternion.Inverse(transform.rotation) /* Quaternion.AngleAxis(180f,Vector3.left)*/  * (limbRb.worldCenterOfMass - transform.position);

        if (limbJoint)
        {
            JointLimited(true);
        }

        limbRb.collisionDetectionMode = mySkeleton.collisionDetectionMode;
        limbRb.useGravity             = mySkeleton.useGravity;
        limbRb.angularDrag            = mySkeleton.angularDrag;
        limbRb.drag = mySkeleton.drag;

        limbRb.interpolation = RigidbodyInterpolation.None;

        if (mySkeleton.physicMat)
        {
            limbCollider.material = mySkeleton.physicMat;
        }

        //ignore colliding with first child with colliders
        foreach (var childCollider in GetComponentsInChildren <Collider>())
        {
            if (childCollider != limbCollider)
            {
                Physics.IgnoreCollision(childCollider, limbCollider, true);
            }
        }


        limbProfile = SetLimbProfile();
        SetLimb();
        //Debug.Log(this.name + " is setted");
    }
Beispiel #3
0
    //RaycastHit raycastHit;

    //public LayerMask layerMask;
    //float initialDistToGround;

    protected override LimbProfile SetLimbProfile()
    {
        LimbProfile prof = new LimbProfile();

        prof.pAnimationRate = 1f;
        prof.pJointSpring   = 1f;
        prof.pAppliedForce  = 0.1f;
        prof.pBreakForce    = float.PositiveInfinity;

        return(prof);
    }
Beispiel #4
0
    protected override LimbProfile SetLimbProfile()
    {
        LimbProfile prof = new LimbProfile();

        prof.pFollowForce  = 1f;
        prof.pFollowTorque = 1f;
        prof.pJointSpring  = 1f;

        prof.pAppliedForce = 1f;

        prof.pFollowRate = 0.5f;

        return(prof);
    }
Beispiel #5
0
    protected override LimbProfile SetLimbProfile()
    {
        LimbProfile prof = new LimbProfile();

        prof.pFollowForce  = 0.8f;
        prof.pFollowTorque = 0.25f;
        prof.pJointSpring  = 0.5f;

        //apply less force to arms
        prof.pAppliedForce = 0.5f;

        prof.pFollowRate = 0.5f;

        return(prof);
    }
Beispiel #6
0
    void Awake()
    {
        mySkeleton = GetComponentInParent <Skeleton>();

        limbRb = GetComponent <Rigidbody>();
        lastRigidbodyPosition = limbRb.position;

        limbJoint = GetComponent <ConfigurableJoint>();

        if (limbJoint)
        {
            Vector3 forward = Vector3.Cross(limbJoint.axis, limbJoint.secondaryAxis);
            Vector3 up      = limbJoint.secondaryAxis;
            localToJointSpace  = Quaternion.LookRotation(forward, up);
            startLocalRotation = transform.localRotation * localToJointSpace;
            jointDrive         = limbJoint.slerpDrive;
        }

        rigidbodyPosToCOM = Quaternion.Inverse(transform.rotation) * (limbRb.worldCenterOfMass - transform.position);

        if (limbJoint)
        {
            JointLimited(true);
        }

        limbRb.collisionDetectionMode = mySkeleton.collisionDetectionMode;
        limbRb.useGravity             = mySkeleton.useGravity;
        limbRb.angularDrag            = mySkeleton.angularDrag;
        limbRb.drag = mySkeleton.drag;

        limbRb.interpolation = RigidbodyInterpolation.None;

        limbProfile = SetLimbProfile();
        SetLimb();
        //Debug.Log(this.name + " is setted");
    }