Beispiel #1
0
    void CreateToothGrabDownJoint(Collider2D collider)
    {
        playerState = PlayerState.YankingToothDown;
        toothJoint  = gameObject.AddComponent <DistanceJoint2D>();
        // toothJoint.frequency = botToothGrabSpringFrequency;



        var otherRigidBody2D = collider.GetComponentInParent <Rigidbody2D>();

        toothJoint.connectedBody = otherRigidBody2D;
        toothJoint.anchor        = Vector2.zero;

        // var otherY =  otherRigidBody2D.transform.position.y;
        // if(transform.position.y <otherY){
        //  transform.position = new Vector3(transform.position.x, otherY + toothGrabDownRadius,0f);
        // }

        var worldGrabPoint            = ToothGrabDownPosition();
        var colliderRelativeGrabPoint = collider.transform.InverseTransformPoint(worldGrabPoint);

        toothJoint.connectedAnchor = new Vector2(0f, 0f);

        toothJoint.maxDistanceOnly = true;
        toothJoint.enableCollision = true;
        toothJoint.distance       *= 1.05f;

        targetYankTooth = collider.gameObject.GetComponentInParent <ToothBehaviour>();

        // grabJoint.distance *= grabJoint.distance * 0.8f;
        toothJoint.autoConfigureDistance = false;
    }
Beispiel #2
0
    void CreateToothGrabUpJoint(Collider2D collider)
    {
        playerState = PlayerState.YankingToothUp;
        toothJoint  = gameObject.AddComponent <DistanceJoint2D>();
        // toothJoint.frequency = botToothGrabSpringFrequency;
        var otherRigidBody2D = collider.GetComponentInParent <Rigidbody2D>();

        toothJoint.connectedBody = otherRigidBody2D;
        toothJoint.anchor        = Vector3.zero; //HairGrabPosition() - transform.position;

        var worldGrabPoint            = HairGrabPosition();
        var colliderRelativeGrabPoint = collider.transform.InverseTransformPoint(worldGrabPoint);

        toothJoint.connectedAnchor = new Vector2(0f, 0f);

        toothJoint.maxDistanceOnly = true;
        //
        toothJoint.enableCollision = true;
        // toothJoint.distance *= 1.05f;

        targetYankTooth = collider.gameObject.GetComponentInParent <ToothBehaviour>();
        toothJoint.autoConfigureDistance = false;
        toothJoint.distance = toothUpGrabJointDistance;
    }