void FixBoxLerpValue()
    {
        GameObject closestBox = null;
        float      distance   = Mathf.Infinity;

        foreach (GameObject box in boxes)
        {
            float boxDistance    = Vector2.Distance(box.transform.position, planetCenter.position);
            float playerDistance = Vector2.Distance(target.position, planetCenter.position);
            float radialDistance = playerDistance - boxDistance - boxVerticalProximityOffset;


            Quaternion boxRotation    = CenterTracker.RotationAroundObject(box.transform, planetCenter);
            Quaternion playerRotation = CenterTracker.RotationAroundObject(target, planetCenter);
            float      angleOffset    = Quaternion.Angle(boxRotation, playerRotation);
            float      arcOffset      = angleOffset * Mathf.Deg2Rad * boxDistance;


            float thisDistance = Mathf.Sqrt(Mathf.Pow(radialDistance, 2) / Mathf.Pow((float)(1 - 0.5 * boxAreaVerticalSquish), 2)
                                            + Mathf.Pow(arcOffset, 2) / Mathf.Pow((float)(1 + 0.5 * boxAreaVerticalSquish), 2));

            if (thisDistance < distance)
            {
                distance   = thisDistance;
                closestBox = box;
            }
        }

        boxLerpValue = Mathf.InverseLerp(boxProximityBegin, boxProximityEnd, distance);
        print(boxLerpValue);
    }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     left   = PlayerControlMap.left;
     right  = PlayerControlMap.right;
     center = GetComponent <CenterTracker>();
     body   = GetComponent <Rigidbody2D>();
 }
Exemplo n.º 3
0
    //Collider2D col;

    // Use this for initialization
    void Start()
    {
        baseScale = transform.localScale;
        flipScale = new Vector3(baseScale.x, -baseScale.y, baseScale.z);
        center    = GetComponent <CenterTracker>();
        body      = GetComponent <Rigidbody2D>();
        //col = GetComponent<Collider2D>();
        body.gravityScale = 0;
    }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     center = GetComponent <CenterTracker>();
     SetupRigidBody();
 }
Exemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     center = GetComponent <CenterTracker>();
 }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     center    = GetComponent <CenterTracker>();
     nodeWidth = 360f / (float)lockingNodes;
 }
 // Use this for initialization
 void Start()
 {
     center = GetComponent <CenterTracker>();
     cc     = GetComponent <CompleteCombo>();
 }
Exemplo n.º 8
0
 void Start()
 {
     center = GetComponent <CenterTracker>();
     body   = GetComponent <Rigidbody2D>();
 }