@HarkBack wrote:
Hello.
I had no problems with sprite rotation at the specified point ... until I decided to make it smooth.
In the end, I got this result: Imgut gifThe sprite makes a full circular turn, and I don't know how to solve it. Tell me how to solve it, please.
Here is my example:float AngleToTarget(float x1, float y1, float x2, float y2, float radian) { var dX = x1 - x2; var dY = y1 - y2; return (float)(Math.Atan2(dY, dX) - radian); } void Update() { Vector2 mp = Exts.GetMousePosOnMap(); Vector2 cp = CenterPos; var target = AngleToTarget(cp.X, cp.Y, mp.X, mp.Y, DEMath.ANGLE_IN_RADIAN_90); Angle += (target - Angle) / 8f; // smooth }
Posts: 3
Participants: 3