/// <summary> /// Update lifetime of one inertia vector, and add its strength /// to the rocket if necessary /// </summary> /// <param name="inertia_vector">inertia vector to be applyied to the rocket</param> /// <returns>return true if lifetime is not expired, else false</returns> private bool UpdateInertiaVector(IntertiaVector inertia_vector) { inertia_vector._lifetime -= Time.deltaTime; if (inertia_vector._lifetime <= 0) { return(false); } _pivot.position += inertia_vector._initial_strength * inertia_vector._lifetime * _inertia_coeff * Time.deltaTime; return(true); }
/// <summary> /// Update position of the rocket /// </summary> private void UpdatePosition() { if (Input.mousePosition != null || Input.mousePosition != Vector3.zero) { _target = Camera.main.ScreenToWorldPoint(Input.mousePosition); _target.z = 0f; } float angular_step = GetAngleStep(); _pivot.right = Quaternion.Euler(0f, 0f, angular_step) * _pivot.right; Vector3 strength_added = _pivot.right * -_speed * Time.deltaTime; _pivot.position += strength_added; IntertiaVector inertia_vector = new IntertiaVector(strength_added); _inertia_vectors.Add(inertia_vector); }