// Use this for initialization void Start() { numUpdates = 0; moving = true; gunBallSpawned = false; initial = true; lastMarker = numUpdates; buffer = 5; fixedTime = Time.fixedDeltaTime; oldVz = gunBallVelocity; range = PhysicsCalculator.calculateRange(boat, target); xDifference = PhysicsCalculator.calculateXDifference(boat, target); collided = false; if (xDifference != 0) { // gamma = PhysicsCalculator.calculateGamma(xDifference, PhysicsCalculator.calculateRange(boat, target)); // gammaDegrees = PhysicsCalculator.toDegrees(gamma); // angle = PhysicsCalculator.calculateAngle(ACCELERATION, xDifference, range, gunBallVelocity); // angleAdjusted = (180 - PhysicsCalculator.toDegrees(angle)) / 2; // angle = PhysicsCalculator.toDegrees(angle) / 2; // oldVz = PhysicsCalculator.calculateGammaVelocity(gunBallVelocity, Mathf.Cos(gamma), Mathf.Sin(angleAdjusted * Mathf.PI / 180)); // oldVy = PhysicsCalculator.calculateGammaYVelocity(gunBallVelocity, angleAdjusted); // oldVx = PhysicsCalculator.calculateGammaVelocity(gunBallVelocity, Mathf.Sin(gamma), Mathf.Sin(angleAdjusted * Mathf.PI / 180)); } else { //calculate theta angle = PhysicsCalculator.calculateAngle(ACCELERATION, xDifference, range, gunBallVelocity); //change angle to degrees angle = PhysicsCalculator.toDegrees(angle) / 2; //calculate Vx oldVx = PhysicsCalculator.calculateXVelocity(gunBallVelocity, angle); //calculate Vy oldVy = PhysicsCalculator.calculateYVelocity(gunBallVelocity, angle); } //---------------- Lab #8 Additions ---------------- tau = PhysicsCalculator.calculateTau(projMass, dragCoefficient); windVelocity = 2.0f; windCoefficient = 0.1f; //---------------- Lab #9 Additions ---------------- jImpulse = PhysicsCalculator.calculateJImpulse((gunBallVelocity - targetVelocity), e, projMass, targetMass); momentumInitial.x = PhysicsCalculator.calculateMomentum(projMass, gunBallVelocity); momentumInitial.y = PhysicsCalculator.calculateMomentum(targetMass, targetVelocity); momentumInitial.z = momentumInitial.x + momentumInitial.y; }
public void pause() { moving = !moving; //react to the collision oldVx = PhysicsCalculator.calculateRecoilVelocity(jImpulse, projMass, gunBallVelocity); gunBallVelocityFinal = oldVx; targetVelocity = PhysicsCalculator.calculateRecoilVelocity(-jImpulse, targetMass, targetVelocity); momentumFinal.x = PhysicsCalculator.calculateMomentum(projMass, oldVx); momentumFinal.y = PhysicsCalculator.calculateMomentum(targetMass, targetVelocity); momentumFinal.z = momentumFinal.x + momentumFinal.y; }