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

0 favourites
  • 5 posts
From the Asset Store
Wall Pin Board is a hyper causal game developed for fun and inspired by YouTube video whose link is given in description
  • 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.

  • Try Construct 3

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

    Try Now 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:

    child x = Parent.X+cos(Parent.Angle)*ParentRadius

    child y = Parent.Y+sin(Parent.Angle)*ParentRadius

    you would then have to add an angle offset that you add to the parent angle to get the child lined up to a particular spot on the parent image, but that is where just placing an imagepoint where you want the child makes the whole process a lot easier...

  • Yep! Thanks R0J0hound and AllanR that's what i needed!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)