0 Favourites

# How do I attach sprite to corner of rotating sprite W/O pin

• 5 posts
• I need the math on how to attach a sprite to a position on another sprite that is rotating WITHOUT using the pin behavior.

I used to know it but I forgot.

Any help?

• well, the easiest way - with no math involved - would be to create an image point on the rotating sprite, and then every tick position the other sprite to the image point.

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Without imagepoints you'll need 3 variables. Two for the positional offset from the center of the parent object and one for the angle difference.

For the positional offset you can either save it in rectangular (x,y) or polar(angle, distance) coordinates.

For rectangular:

every tick:

--- set child position to parent

--- child: move child.dx pixels at parent.angle degrees

--- child: move child.dy pixels at parent.angle+90 degrees

--- child: set angle to parent.angle+child.angdiff

For polar:

every tick:

--- set child position to parent

--- child: move child.dist pixels at parent.angle+child.ang degrees

--- child: set angle to parent.angle+child.angdiff

To calculate the offset it's probably easier to use polar.

set child.ang to angle(parent.x,parent.y,child.x,child.y)-parent.angle

set child.dist to distance(parent.x,parent.y,child.x,child.y)

set child.angdiff to child.angle-parent.angle

• i was going to suggest setting the child's position to: