Skip to main content
removed unnecessary tag & fluff
Source Link
Pikalek
  • 12.5k
  • 5
  • 45
  • 52

I've been trying to get sprites to stay on a set point on another rotating sprite. At the moment, it's very inaccurate, the original position is wrong, and when the rotation is applied the sprite drifts away from the point its intended to stay in. The code I'm currently using is as follows, and I'm pretty sure there's something wrong with it, I just don't know what it is.

rad = sqrt((x-originx)^2 + (y-originy)^2)
x = originx + cos(cameraangle+asin(x-originx)) * rad)
y = originy + (sin(cameraangle+acos(y-originy)) * rad)

If anyone has any idea what it is I'm doing wrong here, and what I should be doing, that would be very helpful.

I've been trying to get sprites to stay on a set point on another rotating sprite. At the moment, it's very inaccurate, the original position is wrong, and when the rotation is applied the sprite drifts away from the point its intended to stay in. The code I'm currently using is as follows, and I'm pretty sure there's something wrong with it, I just don't know what it is.

rad = sqrt((x-originx)^2 + (y-originy)^2)
x = originx + cos(cameraangle+asin(x-originx)) * rad)
y = originy + (sin(cameraangle+acos(y-originy)) * rad)

If anyone has any idea what it is I'm doing wrong here, and what I should be doing, that would be very helpful.

I've been trying to get sprites to stay on a set point on another rotating sprite. At the moment, it's very inaccurate, the original position is wrong, and when the rotation is applied the sprite drifts away from the point its intended to stay in. The code I'm currently using is as follows, and I'm pretty sure there's something wrong with it, I just don't know what it is.

rad = sqrt((x-originx)^2 + (y-originy)^2)
x = originx + cos(cameraangle+asin(x-originx)) * rad)
y = originy + (sin(cameraangle+acos(y-originy)) * rad)
Source Link

Moving a point on a rotating sprite

I've been trying to get sprites to stay on a set point on another rotating sprite. At the moment, it's very inaccurate, the original position is wrong, and when the rotation is applied the sprite drifts away from the point its intended to stay in. The code I'm currently using is as follows, and I'm pretty sure there's something wrong with it, I just don't know what it is.

rad = sqrt((x-originx)^2 + (y-originy)^2)
x = originx + cos(cameraangle+asin(x-originx)) * rad)
y = originy + (sin(cameraangle+acos(y-originy)) * rad)

If anyone has any idea what it is I'm doing wrong here, and what I should be doing, that would be very helpful.