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; }