Ejemplo n.º 1
0
 public void AddNewFixedPulley()
 {
     //fixed pulleys add a support rope to the mass
     pulley_mass.AddSupportRope();
     PulleyController.AddFixedPulleyToScene();
     PulleyController.GetPulleysInScene();   //add all the pulleys back to the list of pulleys
     PulleyController.CalculateMechanicalAdvantage();
     num_fixed_pulleys++;
 }
Ejemplo n.º 2
0
 //when a new pulley is added
 public void AddNewMoveablePulley()
 {
     pulley_mass.AddPulleyToMass();          //add a support pulley to the mass
     //when a moveable pulley is added there is no longer a SupportRope
     pulley_mass.RemoveSupportRope();
     PulleyController.AddMoveablePulleyToScene();
     PulleyController.GetPulleysInScene();   //add all the pulleys back to the list of pulleys
     PulleyController.CalculateMechanicalAdvantage();
     num_moveable_pulleys++;
 }
Ejemplo n.º 3
0
 public void AddNextPulley()
 {
     if (fixedNext)
     {
         AddNewFixedPulley();
     }
     else
     {
         AddNewMoveablePulley();
     }
     //inverted fixed next
     fixedNext = !fixedNext;
     mechAdvantageText.text = PulleyController.GetMechanicalAdvantage().ToString("F0");
 }
Ejemplo n.º 4
0
    private void OnMouseDrag()
    {
        //get the mechanical advantage of the pulley system
        float mechanical_advantage = PulleyController.GetMechanicalAdvantage();



        //Add all moveablepulleys to list
        GameObject[] pulleys = GameObject.FindGameObjectsWithTag("Pulley");
        foreach (GameObject pulley in pulleys)
        {
            if (!pulley.GetComponent <Pulley>().fixedPulley)
            {
                moveable_pulleys.Add(pulley);
            }
        }
        //if mouse moves up then shift handle up and pulleys down
        if (Input.GetAxis("Mouse Y") > 0)
        {
            newPosition        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            transform.position = new Vector3(transform.position.x, newPosition.y, transform.position.z);
            foreach (GameObject pulley in moveable_pulleys)
            {
                Vector3 new_pulley_pos = new Vector3(pulley.transform.position.x, -newPosition.y / mechanical_advantage, pulley.transform.position.z);
                pulley.transform.position = new_pulley_pos;
            }
        }
        //shift handle down and pulleys up
        else if (Input.GetAxis("Mouse Y") < 0)
        {
            newPosition        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            transform.position = new Vector3(transform.position.x, newPosition.y, transform.position.z);
            foreach (GameObject pulley in moveable_pulleys)
            {
                Vector3 new_pulley_pos = new Vector3(pulley.transform.position.x, -newPosition.y / mechanical_advantage, pulley.transform.position.z);
                pulley.transform.position = new_pulley_pos;
            }
        }
        //returns +1 if no pulleys in the pulley list
        float mass_x_pos = PulleyController.AverageMoveablePulleyPositionX();

        //move the mass to the correct position
        if (mass_x_pos <= 0)
        {
            mass.position = new Vector3(mass_x_pos, -newPosition.y / mechanical_advantage + mass_offset, mass.position.z);
        }
    }