Example #1
0
    private void Update()
    {
        if (forceType == Forces.TorqueTest)
        {
            ApplyTorque(localSpace, new Vector2(-5, 0));
        }
        if (forceType == Forces.Gravity)
        {
            AddForce(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass));
        }

        else if (forceType == Forces.NormalForce)
        {
            AddForce(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1.0f, 0.0f).normalized));
        }

        else if (forceType == Forces.SlidingForce)
        {
            AddForce(ForceGenerator.GenerateForce_Sliding(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1f, 1f).normalized)));
        }

        else if (forceType == Forces.StaticFriction)
        {
            Vector2 Normal = ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1.0f, 1.0f).normalized);
            AddForce(ForceGenerator.GenerateForce_friction_static(Normal, new Vector2(5, 5), 0.5f));
        }

        else if (forceType == Forces.KinematicFriction)
        {
            AddForce(ForceGenerator.GenerateForce_friction_kinetic((ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1f, 1f).normalized)), new Vector2(1, 1), 0.5f));
        }

        else if (forceType == Forces.Drag)
        {
            AddForce(ForceGenerator.GenerateForce_drag(new Vector2(1, 1), new Vector2(0.5f, 1), 1.0f, 2.0f, 0.2f));
        }

        else if (forceType == Forces.Spring)
        {
            AddForce(ForceGenerator.GenerateForce_spring(position, new Vector2(0, -2), 10.0f, 1.0f));
        }

        else if (forceType == Forces.Lab3Bonus)
        {
            Vector2 gravity = ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass);
            //AddForce(gravity);
            Vector2 Normal   = ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1.0f, 1.0f).normalized);
            Vector2 Friction = ForceGenerator.GenerateForce_friction_kinetic((ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1f, 1f).normalized)), new Vector2(1, 1), 0.5f);
            //AddForce(Normal);
            AddForce(Friction);
            //ApplyTorque(localSpace, -Friction);
            ApplyTorque(localSpace, gravity);
        }
    }
Example #2
0
 // Update is called once per frame
 void Update()
 {
     applyTorque();
     if (forcetype == forcegen.Gravity)
     {
         AddForce(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up));
     }
     if (forcetype == forcegen.Normal)
     {
         AddForce(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), surfaceNormalUnit));
     }
     if (forcetype == forcegen.Sliding)
     {
         AddForce(ForceGenerator.GenerateForce_Sliding(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), surfaceNormalUnit)));
     }
     if (forcetype == forcegen.Friction_Static)
     {
         AddForce(ForceGenerator.GenerateForce_Friction_Static(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), surfaceNormalUnit), f_opposing, frictionCoefficientStatic));
     }
     if (forcetype == forcegen.Friction_Kinetic)
     {
         AddForce(ForceGenerator.GenerateForce_Friction_Kinetic(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), surfaceNormalUnit), velocity, frictionCoefficientKinetic));
     }
     if (forcetype == forcegen.Drag)
     {
         AddForce(ForceGenerator.GenerateForce_Sliding(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), surfaceNormalUnit)));
         AddForce(ForceGenerator.GenerateForce_Drag(velocity, fluidVelocity, fluidDensity, objectAreaCrossSection, objectDragCoefficient));
     }
     if (forcetype == forcegen.Spring)
     {
         //AddForce(ForceGenerator.GenerateForce_Spring(position, anchorPosition, springRestingLength,springStiffnessCoefficient));
         AddForce(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up));
         AddForce(ForceGenerator.GenerateForce_Spring(position, -position, springRestingLength, springStiffnessCoefficient));
     }
     if (forcetype == forcegen.None)
     {
     }
     if (forcetype == forcegen.SphereRoll)
     {
         AddForce(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up));
         AddForce(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), surfaceNormalUnit));
         AddForce(ForceGenerator.GenerateForce_Friction_Static(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(Mass, kGravity, Vector2.up), surfaceNormalUnit), f_opposing, frictionCoefficientStatic));
     }
 }
Example #3
0
    void UpdateForce()
    {
        // Lab 2 Step 3
        //f_gravity = f = mg = ma
        Vector3 f_gravity = forces.mass * new Vector3(0.0f, -9.8f);

        Vector3 f_normal = ForceGenerator.GenerateForce_Normal(f_gravity, transform.up);

        // AddForce(f_gravity); // works
        if (forces.generateGravity)
        {
            AddForce(ForceGenerator.GenerateForce_Gravity(forces.mass, -9.8f, Vector3.up));
        }

        if (forces.generateNormal)
        {
            AddForce(ForceGenerator.GenerateForce_Normal(f_gravity, forces.surfaceNormal_unit)); // works? more testing (surface normal is 0, 1)
        }
        if (forces.generateSliding)
        {
            AddForce(ForceGenerator.GenerateForce_Sliding(f_gravity, f_normal));  // (surface normal is 0,1)
        }
        if (forces.generateStaticsFriction)
        {
            AddForce(ForceGenerator.GenerateForce_Friction_Static(f_normal, forces.frictionOpposingForce, forces.frictionCoeff_static)); // works (surface normal is 1,1) FOF = (-3,0) FCS = 0.9
        }
        if (forces.generateKineticFriction)
        {
            AddForce(ForceGenerator.GenerateForce_Friction_Kinetic(f_normal, particle3DTransform.velocity, forces.frictionCoeff_kinetic));  // works surface = (1,1) initVel = 15 FCK = 0.3
        }
        if (forces.generateDrag)
        {
            AddForce(ForceGenerator.GenerateForce_Drag(particle3DTransform.velocity, forces.fluidVelocity, forces.fluidDensity, forces.objArea_CrossSection, forces.objDragCoeff));  // not sure if this works ask dan... IV = 1, FV = 1, FD = 1, OACS = 1.5, ODC=1.05
        }
        if (forces.generateSpring && particle3DTransform.position.magnitude != 0)
        {
            AddForce(ForceGenerator.GenerateForce_Spring(particle3DTransform.position, forces.anchorPos, forces.springRestingLength, forces.springStiffnesCoeff)); // pos = 0,100 , AP = 0,0 , SRL = 0.1, SSC = 3 , fricCoKin = 0.15 (turn on gravity and kin fric
        }
        AddForce(forces.basicForce);
    }
Example #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (forceType == Forces.Gravity)
        {
            AddForce(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass));
        }

        else if (forceType == Forces.NormalForce)
        {
            AddForce(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(5.0f, 0.0f).normalized));
        }

        else if (forceType == Forces.SlidingForce)
        {
            AddForce(ForceGenerator.GenerateForce_Sliding(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1f, 1f).normalized)));
        }

        else if (forceType == Forces.StaticFriction)
        {
            Vector2 Normal = ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1.0f, 1.0f).normalized);
            AddForce(ForceGenerator.GenerateForce_friction_static(Normal, new Vector2(5, 5), 0.2f));
        }

        else if (forceType == Forces.KinematicFriction)
        {
            AddForce(ForceGenerator.GenerateForce_friction_kinetic((ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(-10.0f, Vector2.up, mass), new Vector2(1f, 1f).normalized)), new Vector2(1, 1), 0.5f));
        }

        else if (forceType == Forces.Drag)
        {
            AddForce(ForceGenerator.GenerateForce_drag(new Vector2(1, 1), new Vector2(0.5f, 1), 1.0f, 2.0f, 0.2f));
        }

        else if (forceType == Forces.Spring)
        {
            AddForce(ForceGenerator.GenerateForce_spring(position, new Vector2(0, -2), 10.0f, 1.0f));
        }

        //if Euler is selected in the drop down menu, do this
        if (calculationType == Physics.Euler)
        {
            UpdatePositionEulerExplicit(Time.fixedDeltaTime);
            transform.position = position;                         //set the new position
            UpdateRotationEulerExplicit(Time.fixedDeltaTime);
            transform.eulerAngles = new Vector3(0f, 0f, rotation); //set the new rotation
            //move cubes back and forth
            //acceleration.x = -Mathf.Sin(Time.time - startTime);
        }

        //if Kinematic is selected, do this
        else if (calculationType == Physics.Kinematic)
        {
            UpdatePositionKinematic(Time.fixedDeltaTime);
            transform.position = position;                         //set the new position
            UpdateRotationKinematic(Time.fixedDeltaTime);
            transform.eulerAngles = new Vector3(0f, 0f, rotation); //set the new rotation
            //move the cubes in a circle
            //acceleration.x = Mathf.Sin(Time.time - startTime);
            //acceleration.y = Mathf.Cos(Time.time - startTime);
        }

        UpdateAcceleration();
    }
Example #5
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //rb.AddTorque(speed, ForceMode2D.Force);
        // step 3
        //Integrate
        if (isEuler == true)
        {
            UpdateEuler();
        }

        //AddForce(new Vector2(0.0f,2.0f));

        //ApplyTorque();

        //CollisionHull2D.instance.TestCollsionVsCircle(other);

        // SHAPES
        if (Shape == Shapes.NONE)
        {
            // DO NOTHING
        }

        if (Shape == Shapes.CUBE)
        {
            CubeInvInertiaCalc();
        }

        else if (Shape == Shapes.SPHERE)
        {
            SphereInvInertiaCalc();
        }

        else if (Shape == Shapes.CYLINDER)
        {
            CylinderInvInertiaCalc();
        }



        //Update the Accerleration
        UpdateAcceleration();
        //UpdateAngularAcceleration();

        // apply to transform
        transform.position = position;

        // step 4
        // test

        // f_gravity: f = mg
        // Vector2 f_gravity = mass * new Vector2(0.0f, -9.8f);
        Vector2 gravity = ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up);

        if (Test == Forces.NONE)
        {
            // NOTHING HAPPENS HERE
        }

        if (Test == Forces.NORMAL)
        {
            Vector2 normal = ForceGenerator.GenerateForce_normal(-gravity, force);
            AddForce(ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up));
            AddForce(normal);
        }

        else if (Test == Forces.GRAVITY)
        {
            AddForce(ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up));
        }

        else if (Test == Forces.SLIDE)
        {
            Vector2 sliding_normal = ForceGenerator.GenerateForce_normal(gravity, new Vector2(Mathf.Sin(45), Mathf.Sin(45)));
            AddForce(ForceGenerator.GenerateForce_sliding(gravity, sliding_normal));
            AddForce(ForceGenerator.GenerateForce_friction_kinetic(sliding_normal, velocity, friction));
        }

        else if (Test == Forces.DRAG)
        {
            // vel 2,0
            AddForce(ForceGenerator.GenerateForce_drag(velocity, new Vector2(1, 0), 0.5f, 10.0f, 0.1f));
        }

        else if (Test == Forces.SLIDINGANDKINETIC)
        {
            //Vector2 gravity = ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up);
            Vector2 static_friction_normal = ForceGenerator.GenerateForce_normal(gravity, new Vector2(Mathf.Sin(45), Mathf.Sin(-45)));
            Vector2 f_opposing             = new Vector2(14.0f, 0.0f);
            AddForce(f_opposing);
            AddForce(ForceGenerator.GenerateForce_sliding(gravity, static_friction_normal));
            AddForce(ForceGenerator.GenerateForce_friction_static(static_friction_normal, force, friction));
        }

        else if (Test == Forces.SLIDINGANDSTATIC)
        {
            // set vel 1,-1
            //Vector2 gravity = ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up);
            Vector2 kinetic_friction_normal = ForceGenerator.GenerateForce_normal(gravity, new Vector2(Mathf.Sin(45), Mathf.Sin(-45)));
            AddForce(ForceGenerator.GenerateForce_sliding(gravity, kinetic_friction_normal));
            AddForce(ForceGenerator.GenerateForce_friction_kinetic(kinetic_friction_normal, velocity, friction));
        }

        else if (Test == Forces.SPRING)
        {
            // set vel 0,-8
            Vector2 anchorPosition = GameObject.Find("Anchor").transform.position;
            AddForce(ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up));
            AddForce(ForceGenerator.GenerateForce_spring(transform.position, anchorPosition, 3.0f, 2.0f, velocity));
        }
    }
Example #6
0
    private void FixedUpdate()
    {
        switch (positionType)
        {
        case PosIntegrationType.EulerExplicit:
            UpdatePositionEulerExplicit(Time.fixedDeltaTime);
            break;

        default:
            UpdatePositionKinematic(Time.fixedDeltaTime);
            break;
        }

        switch (rotationType)
        {
        case RotIntegrationType.EulerExplicit:
            UpdateRotationEulerExplicit(Time.fixedDeltaTime);
            break;

        default:
            UpdateRotationKinematic(Time.fixedDeltaTime);
            break;
        }

        //lab03
        UpdateAngularAcceleration();
        UpdateAcceleration();

        transform.position = position;

        Vector2 gravitationalForce   = ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up);
        Vector2 normalForce          = ForceGenerator.GenerateForce_Normal(-gravitationalForce, testFloor.transform.up);
        Vector2 slideForce           = ForceGenerator.GenerateForce_Sliding(gravitationalForce, normalForce);
        Vector2 frictionForce        = ForceGenerator.GenerateForce_Friction(normalForce, slideForce, velocity, frictionStatic, frictionKinetic);
        Vector2 dragForce            = ForceGenerator.GenerateForce_Drag(velocity, new Vector2(0.2f, 0.0f), 10.0f, 10.0f, 4.0f);
        Vector2 springForce          = ForceGenerator.GenerateForce_Spring(transform.position, testSpringAnchor.position, springRestingLength, springStrength * springStrength);
        Vector2 springDampForce      = ForceGenerator.GenerateForce_SpringDamping(mass, velocity, springStrength, 5.0f);
        Vector2 springMaxLengthForce = ForceGenerator.GenerateForce_SpringWithMax(transform.position, testSpringAnchor.position, springRestingLength, springStrength * springStrength, maxSpringLength);

        switch (forceType)
        {
        case ForceType.gravity:
            AddForce(gravitationalForce);
            break;

        case ForceType.normal:
            AddForce(normalForce);
            break;

        case ForceType.slide:
            AddForce(slideForce);
            break;

        case ForceType.friction:
            AddForce(slideForce);
            AddForce(frictionForce);
            break;

        case ForceType.drag:
            AddForce(dragForce);
            break;

        case ForceType.spring:
            AddForce(springForce);
            break;

        case ForceType.springDamping:
            AddForce(springForce);
            AddForce(springDampForce);
            AddForce(gravitationalForce);
            break;

        case ForceType.springWithMaxLength:
            AddForce(springMaxLengthForce);
            AddForce(springDampForce);
            AddForce(gravitationalForce);
            break;

        case ForceType.none:
            //Debug.Log("We ain't movin chief.");
            break;

        default:
            AddForce(gravitationalForce);
            break;
        }

        //lab03
        ApplyTorque(pointApplied, forceApplied);

        //clamps rotation to 360
        SetRotation(rotation %= 360.0f);
        rotAcceleration       = angularAccel;
    }
Example #7
0
    /*
     *  Lab 1
     *  Integrate user friendly menu.
     */
    // Get selectable items from the inspector menu.
    private void GetInspectorItems()
    {
        /*
         *  Lab 1 Step 3
         */

        // Integrate.
        if (positionType == PositionType.Euler)
        {
            UpdatePositionEulerExplicit(Time.fixedDeltaTime);
        }
        else if (positionType == PositionType.Kinematic)
        {
            UpdatePositionKinematic(Time.fixedDeltaTime);
        }

        if (rotationType == RotationType.Euler)
        {
            UpdateRotationEulerExplicit(Time.fixedDeltaTime);
        }
        else if (rotationType == RotationType.Kinematic)
        {
            UpdateRotationKinematic(Time.fixedDeltaTime);
        }

        if (gravityActive)
        {
            // Gravity force.
            AddForce(ForceGenerator.GenerateForce_Gravity(mass, GRAVITY, Vector2.up));
        }

        if (springActive)
        {
            // Spring force.
            AddForce(ForceGenerator.GenerateForce_Spring(springAnchor.position, transform.position, springRestLength, springStiffness));
        }

        if (staticFrictionActive)
        {
            // Static friction force.
            AddForce(ForceGenerator.GenerateForce_Friction_Static(staticFrictionNormal, staticFrictionOpposingForce, staticFrictionCoefficient));
        }

        if (kinematicFrictionActive)
        {
            // Kinematic friction force.
            AddForce(ForceGenerator.GenerateForce_Friction_Kinetic(kinematicNormalForce, velocity, kinematicFrictionCoefficient));
        }

        if (slidingActive)
        {
            // Sliding force.
            AddForce(ForceGenerator.GenerateForce_Sliding(ForceGenerator.GenerateForce_Gravity(mass, GRAVITY, worldUp), slidingNormalForce));
        }

        if (dragActive)
        {
            // Drag force.
            AddForce(ForceGenerator.GenerateForce_Drag(velocity, fluidVelocity, fluidDensity, objectCrossSection, dragCoefficient));
        }

        if (normalActive)
        {
            // Normal force.
            AddForce(ForceGenerator.GenerateForce_Normal(ForceGenerator.GenerateForce_Gravity(mass, GRAVITY, worldUp), surfaceNormal));
        }

        if (dampingSpringActive)
        {
            // Damping spring force.
            AddForce(ForceGenerator.GenerateForce_Spring_Damping(position, springAnchor.position, springRestLength, springStiffness, springDamping, springConstant, velocity));
        }

        return;
    }
Example #8
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (isPlayer) // only runs for the player
        {
            AddForce(ForceGenerator.GenerateForce_Gravity(-0.5f, transform.up, mass));

            /*if (Input.GetAxis("Vertical") < 0) //down
             * {
             *  AddForce(ForceGenerator.GenerateForce_Gravity(-2.0f, transform.up, mass));
             *  //AddForce(ForceGenerator.GenerateForce_Normal(new Vector2(0, 0.5f), new Vector2(0.0f, -1.0f).normalized));
             * }
             * else if (Input.GetAxis("Vertical") > 0) //up
             * {
             *  AddForce(ForceGenerator.GenerateForce_Gravity(2.0f, transform.up, mass));
             *  //AddForce(ForceGenerator.GenerateForce_Normal(new Vector2(0, 0.5f), new Vector2(0.0f, 1.0f).normalized));
             * }
             * else if (Input.GetAxis("Horizontal") > 0) //right
             * {
             *  ApplyTorque(transform.position, ForceGenerator.GenerateForce_Gravity(2.0f, Vector2.up, mass));
             *
             *  //ApplyTorque(new Vector2(transform.position.x - 0.25f, transform.position.y), ForceGenerator.GenerateForce_Gravity(2.0f, Vector2.up, mass));
             * }
             * else if (Input.GetAxis("Horizontal") < 0) //left
             * {
             *  ApplyTorque(transform.position, ForceGenerator.GenerateForce_Gravity(-2.0f, Vector2.up, mass));
             *  //ApplyTorque(new Vector2(transform.position.x + 0.25f,transform.position.y), ForceGenerator.GenerateForce_Gravity(-2.0f, Vector2.up, mass));
             * }*/
            if (transform.eulerAngles.z >= 90.0f && transform.eulerAngles.z < 180f && !(Input.GetAxis("Horizontal") > 0.0f))
            {
                transform.eulerAngles = new Vector3(0f, 0f, 90f);
                StopTorque();
            }
            if (transform.eulerAngles.z <= 270.0f && transform.eulerAngles.z > 180f && !(Input.GetAxis("Horizontal") < 0.0f))
            {
                transform.eulerAngles = new Vector3(0f, 0f, 270f);
                StopTorque();
            }
            if (Mathf.Abs(Input.GetAxis("Vertical")) > 0 && fuel > 0)
            {
                AddForce(ForceGenerator.GenerateForce_Gravity(2.0f, transform.up * Input.GetAxis("Vertical"), mass));
                --fuel;
            }
            if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0)
            {
                ApplyTorque(transform.position, ForceGenerator.GenerateForce_Gravity(2.0f, (new Vector2(0, 1) * Input.GetAxis("Horizontal")) * -1, mass));
            }
            else
            {
                StopTorque();
            }
        }


        //if Euler is selected in the drop down menu, do this
        if (calculationType == Physics.Euler)
        {
            UpdatePositionEulerExplicit(Time.fixedDeltaTime);
            transform.position = position;                         //set the new position
            UpdateRotationEulerExplicit(Time.fixedDeltaTime);
            transform.eulerAngles = new Vector3(0f, 0f, rotation); //set the new rotation
            //move cubes back and forth
            //acceleration.x = -Mathf.Sin(Time.time - startTime);
        }

        //if Kinematic is selected, do this
        else if (calculationType == Physics.Kinematic)
        {
            UpdatePositionKinematic(Time.fixedDeltaTime);
            transform.position = position;                         //set the new position
            UpdateRotationKinematic(Time.fixedDeltaTime);
            transform.eulerAngles = new Vector3(0f, 0f, rotation); //set the new rotation
            //move the cubes in a circle
            //acceleration.x = Mathf.Sin(Time.time - startTime);
            //acceleration.y = Mathf.Cos(Time.time - startTime);
        }
        UpdateAngularAcceleration();
        UpdateAcceleration();
    }
Example #9
0
    // Update is called once per frame
    void FixedUpdate()
    {
        // step 3
        //Integrate
        if (isEuler == true)
        {
            UpdateEuler();
        }

        // Update the Accerleration
        UpdateAcceleration();

        // apply to transform
        transform.position = position;


        // step 4
        // test

        // f_gravity: f = mg
        // Vector2 f_gravity = mass * new Vector2(0.0f, -9.8f);
        Vector2 gravity        = ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up);
        Vector2 anchorPosition = GameObject.Find("Anchor").transform.position;

        if (Test == Forces.NORMAL)
        {
            Vector2 normal = ForceGenerator.GenerateForce_normal(-gravity, force);
            AddForce(ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up));
            AddForce(normal);
        }


        else if (Test == Forces.GRAVITY)
        {
            AddForce(ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up));
        }

        else if (Test == Forces.SLIDE)
        {
            Vector2 sliding_normal = ForceGenerator.GenerateForce_normal(gravity, new Vector2(Mathf.Sin(45), Mathf.Sin(45)));
            AddForce(ForceGenerator.GenerateForce_sliding(gravity, sliding_normal));
            AddForce(ForceGenerator.GenerateForce_friction_kinetic(sliding_normal, velocity, friction));
        }

        else if (Test == Forces.DRAG)
        {
            // vel 2,0
            AddForce(ForceGenerator.GenerateForce_drag(velocity, new Vector2(1, 0), 0.5f, 10.0f, 0.1f));
        }

        else if (Test == Forces.SLIDINGANDKINETIC)
        {
            //Vector2 gravity = ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up);
            Vector2 static_friction_normal = ForceGenerator.GenerateForce_normal(gravity, new Vector2(Mathf.Sin(45), Mathf.Sin(-45)));
            Vector2 f_opposing             = new Vector2(14.0f, 0.0f);
            AddForce(f_opposing);
            AddForce(ForceGenerator.GenerateForce_sliding(gravity, static_friction_normal));
            AddForce(ForceGenerator.GenerateForce_friction_static(static_friction_normal, force, friction));
        }

        else if (Test == Forces.SLIDINGANDSTATIC)
        {
            // set vel 1,-1
            //Vector2 gravity = ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up);
            Vector2 kinetic_friction_normal = ForceGenerator.GenerateForce_normal(gravity, new Vector2(Mathf.Sin(45), Mathf.Sin(-45)));
            AddForce(ForceGenerator.GenerateForce_sliding(gravity, kinetic_friction_normal));
            AddForce(ForceGenerator.GenerateForce_friction_kinetic(kinetic_friction_normal, velocity, friction));
        }

        else if (Test == Forces.SPRING)
        {
            // set vel 0,-8
            AddForce(ForceGenerator.GenerateForce_Gravity(mass, -9.8f, Vector2.up));
            AddForce(ForceGenerator.GenerateForce_spring(transform.position, anchorPosition, 3.0f, 2.0f, velocity));
        }
    }