void Update() { Vector3 rotation = initialRotation + motor.getCurrentRotation(); crossNear.rotation = Quaternion.Euler(rotation.x, rotation.y, 0.0f); crossFar.rotation = Quaternion.Euler(rotation.x, rotation.y, 0.0f); }
void FixedUpdate() { if (ship.IsDead()) { shakeTimer = shakeTime; return; } Vector3 shake = Vector3.zero; if (shakeTimer <= shakeTime) { float rad = Random.Range(0.0f, 360.0f); float magnitude = (1.0f - shakeTimer / shakeTime) * shakeMagnitude; shake.x = magnitude * Mathf.Cos(rad); shake.y = magnitude * Mathf.Sin(rad); shake = ship.transform.rotation * shake; shakeTimer += Time.deltaTime; } transform.position = Vector3.SmoothDamp(transform.position, followPoint.position, ref velocity, thrustSmoothing) + shake; Vector3 shipRotation = motor.getCurrentRotation(); Quaternion target; if (motor.IsManeuvering()) { Vector3 targetUp = Quaternion.Euler(shipRotation.x, shipRotation.y, shipRotation.z * curRollDamping) * Vector3.up; Vector3 up = Vector3.SmoothDamp(transform.up, targetUp, ref upVelocity, 0.01f); target = Quaternion.LookRotation(lookAt.position - transform.position, up); } else { target = Quaternion.Euler(shipRotation.x / 3.0f, shipRotation.y, 0.0f); } transform.rotation = smoothDampQuat(transform.rotation, target, rotationalSmoothing); if (Mathf.Abs(camera.fieldOfView - fovTarget) > Util.Epsilon) { float vel = 0.0f; camera.fieldOfView = Mathf.SmoothDamp(camera.fieldOfView, fovTarget, ref vel, 0.1f); } }
private void Update() { /* motor.SetManeuver(ShipMotor.Maneuvers.IMMELMANN); */ /* motor.Boost(true); */ float throttle = 1.0f; float pitch = 0.0f; Vector3 rotation = motor.getCurrentRotation(); rotation.x = 0.0f; bool hit = Physics.Raycast(transform.position, Quaternion.Euler(rotation) * Vector3.forward, 1000.0f); if (hit) { pitch = -1.0f; } motor.SetMovement(throttle, pitch, 0.0f, 0.0f); cannon.setFiring(true); }