Ejemplo n.º 1
0
    private void SpawnArc(ICylinder a, ICylinder b)
    {
        /* Spawn an arc between two cylinders
         * Calculate the origin and the direction by taking into consideration
         * all possible cylinder directions
         */

        Vector3 position1 = a.transform.position;
        Vector3 position2 = b.transform.position;
        Vector3 position3 = position1 + a.transform.up * a.height_;
        Vector3 position4 = position2 + b.transform.up * b.height_;

        Vector3 arc_origin;
        Vector3 arc_dir1;
        Vector3 arc_dir2;

        if (position1 == position2)
        {
            arc_origin = position1;
            arc_dir1   = a.transform.up;
            arc_dir2   = b.transform.up;
        }
        else if (position1 == position4)
        {
            arc_origin = position1;
            arc_dir1   = a.transform.up;
            arc_dir2   = -b.transform.up;
        }
        else if (position2 == position3)
        {
            arc_origin = position2;
            arc_dir1   = -a.transform.up;
            arc_dir2   = b.transform.up;
        }
        else if (position4 == position3)
        {
            arc_origin = position3;
            arc_dir1   = -a.transform.up;
            arc_dir2   = -b.transform.up;
        }
        else
        {
            /* The two vectors don't form an angle */
            return;
        }

        arc_previous_ = Instantiate(prefab_arc_, arc_origin, Quaternion.identity);
        arc_previous_.transform.parent = transform;

        ArcRenderer arc = arc_previous_.GetComponent <ArcRenderer>();

        arc.X_      = arc_dir1;
        arc.W_      = arc_dir2;
        arc.Radius_ = (a.height_ + b.height_) / 4;
    }
Ejemplo n.º 2
0
    void Awake()
    {
        gameManager  = FindObjectOfType <GameManager>();
        audioManager = FindObjectOfType <AudioManager>();
        rb           = GetComponent <Rigidbody2D>();
        anim         = GetComponent <Animator>();
        bitPhysics   = GetComponent <BitPhysics>();
        arcRenderer  = GetComponentInChildren <ArcRenderer>();

        if (GameManager.GetCurrentSceneIndex() >= 4 || GameManager.GetCurrentSceneIndex() == 0)
        {
            canThrow = true;
        }
    }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        local_to_world_ = transform.localToWorldMatrix;

        /* Calcualte plane normals, torsion angle value, and sign */
        normal1_ = Vector3.Normalize(GetPlaneNormal(pos1_, pos2_, pos3_));
        normal2_ = Vector3.Normalize(GetPlaneNormal(pos2_, pos3_, pos4_));
        float angle = Mathf.Acos(Vector3.Dot(normal1_, normal2_));
        float sign  = Mathf.Sign(Vector3.Dot(normal2_, pos1_ - pos2_));

        /* Set the positions for the two torsion plane objects */
        Transform p1 = transform.GetChild(0);

        plane1_       = p1.GetComponent <TorsionPlane>();
        plane1_.pos1_ = pos3_;
        plane1_.pos2_ = pos2_;
        plane1_.pos3_ = pos1_;

        Transform    p2     = transform.GetChild(1);
        TorsionPlane plane2 = p2.GetComponent <TorsionPlane>();

        plane2.pos1_ = pos2_;
        plane2.pos2_ = pos3_;
        plane2.pos3_ = pos4_;

        /* Line renderer for the axis line */
        lr_ = GetComponent <LineRenderer>();
        lr_.positionCount = 0;
        lr_.startWidth    = 0.003f;
        lr_.endWidth      = 0.003f;

        /* Soawn an arc for the torsion angle */
        GameObject temp = Instantiate(prefab_arc, (pos2_ + pos3_) / 2, Quaternion.identity);

        temp.transform.parent = transform;

        /* Calcualte the X and W vectors required for the arc, based on the arc logic */
        Vector3 dir1 = Vector3.Normalize(-Vector3.Cross(normal1_, Vector3.Normalize(pos2_ - pos3_)));
        Vector3 dir2 = Vector3.Normalize(-Vector3.Cross(normal2_, Vector3.Normalize(pos2_ - pos3_)));

        /* Spawn the arc */
        ArcRenderer arc = temp.GetComponent <ArcRenderer>();

        arc.X_              = dir1;
        arc.W_              = dir2;
        arc.Radius_         = 0.055f;
        arc.angle_positive_ = sign > 0;
    }
Ejemplo n.º 4
0
        protected override void OnAwake()
        {
            VRLog.Debug("Awake!");
            ArcRenderer = new GameObject("Arc Renderer").AddComponent <ArcRenderer>();
            ArcRenderer.transform.SetParent(transform, false);
            ArcRenderer.gameObject.SetActive(false);

            // -- Create indicator
            // Prepare rumble definitions
            _TravelRumble = new TravelDistanceRumble(500, 0.1f, transform);
            _TravelRumble.UseLocalPosition = true;

            _Visualization = PlayAreaVisualization.Create(_ProspectedPlayArea);
            DontDestroyOnLoad(_Visualization.gameObject);

            SetVisibility(false);
        }
Ejemplo n.º 5
0
    void Transition()
    {
        float newZ = 0;

        if (!GetComponent <CharacterController>().isMounted)
        {
            float y = currentLocation.start.position.y - currentLocation.end.position.y;
            t1   = (currentLocation.start.position.y - transform.position.y) / y;
            newZ = Mathf.Lerp(currentLocation.obj.transform.position.z, currentLocation.objBelow.transform.position.z, t1);
        }
        else
        {
            ArcRenderer arc = FrogScript.instance.arc;
            float       y   = arc.transitionStart.y - arc.transitionPoint.y;
            t1   = (arc.transitionStart.y - transform.position.y) / y;
            newZ = Mathf.Lerp(arc.transitionStart.z, arc.transitionPoint.z, t1);

            FrogScript.instance.transform.position = new Vector3(FrogScript.instance.transform.position.x, FrogScript.instance.transform.position.y, newZ);
        }


        transform.position = new Vector3(transform.position.x, transform.position.y, newZ);
    }
 void Awake()
 {
     trackedObj  = GetComponent <SteamVR_TrackedObject>();
     arcRenderer = arc.GetComponent <ArcRenderer>();
     player      = transform.parent.gameObject;
 }