public void UpdateIndicator(GravityIndicator indicator, GravityField field) { Vector2 indicatorGravity = field.GetGravityAtPosition(indicator.transform.position); indicator.GravityForce = indicatorGravity; float angle = Vector2.SignedAngle(indicator.transform.right, indicatorGravity); indicator.transform.Rotate(0.0f, 0.0f, angle); float strengthT = Mathf.InverseLerp(minFieldStrength, maxFieldStrength, indicatorGravity.magnitude); float arrowLength = Mathf.Lerp(minArrowLength, maxArrowLength, strengthT); indicator.SetArrowLength(arrowLength); }
void FixedUpdate() { Vector2 propulsionForce = transform.right * propulsionForceScale; Vector2 gravityForce = activeField.GetGravityAtPosition(transform.position); Vector2 dragForce = -velocity * orbDrag; velocity += (propulsionForce + gravityForce + dragForce) * Time.fixedDeltaTime; float angle = Vector2.SignedAngle(transform.right, velocity); transform.Rotate(0.0f, 0.0f, angle); transform.Translate(velocity); }