/// <summary> /// Generate attraction force depending on a mover. /// <summary> /// <param name="mover">Mover instance</param> /// <returns>Attraction force vector</returns> public virtual Vector2 Attract(SimpleMover mover) { var force = GlobalPosition - mover.GlobalPosition; var length = Mathf.Clamp(force.Length(), MinForce, MaxForce); float strength = (Gravitation * Mass * mover.Mass) / (length * length); return(force.Normalized() * strength); }
/// <summary> /// Generate attraction force depending on a mover. /// <summary> /// <param name="mover">Mover instance</param> /// <returns>Attraction force vector</returns> public override Vector2 Attract(SimpleMover mover) { return(-base.Attract(mover)); }