Constrain object to a rotating object

BaccardaBaccarda Member Posts: 122

Hello everyone.
Ive made rotating rock which is uneven shaped and added multiple collision points, but i cant get them to rotate at the same angle as the rock. If you have any ideas, please share it, because without it i don't see any point of continuing my work. :/

Thanks in advance

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @janis.piziks@gmail.com

    Use this, it will do all the calculations for you:

    http://forums.gamesalad.com/discussion/75220/fast-constrain-linkmachine-v2

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    Edit, just noticed you are on a PC . . . . So here's the method.

    . . . . . . . . . . . . . .

    Make 3 real game attributes:

    Mx
    My
    Mr

    . . . . . . . . . . . . . .

    In the Rock actor:

    Constrain Mx to self X
    Constrain My to self Y
    Constrain Mr to self Rotation

    . . . . . . . . . . . . . .

    In the Collision Point actor:

    Make 5 real attributes:

    Lx
    Ly
    Lr
    Mag
    Angle

    Change Lx to Self X
    Change Ly to Self Y
    Change Lr to Self Rotation
    Change Mag to magnitude( game.Mx - self.Position.X , game.My - self.Position.Y )
    Change Angle to vectorToAngle( self.Position.X - game.Mx , self.Position.Y - game.My )

    Constrain self X to self.Mag *cos( self.Angle + game.Mr )+ game.Mx
    Constrain self Y to self.Mag *sin( self.Angle + game.Mr )+ game.My
    Constrain self Rotation to self.Lr + game.Mr

    . . . . . . . . . . . . . .

    Now simply position, size, rotate your rock to however you like.
    Then drag the collision point actors into the scene and position, size, rotate to however you like.

    When you play the game the collision point actors will stick to the rock how you placed them, even if the rock moves and spins and bounces around the scene.

    Note: make sure your collision point actors are above the rock in the layers.

  • LovejoyLovejoy Member Posts: 2,078

    @Socks I sure hope that custom collision shapes are like the following. Look at 1:15 to about 1:40 it would make things much easier.

    Fortuna Infortuna Forti Una

  • BaccardaBaccarda Member Posts: 122

    This is nightmare :/

    About Lx, Ly, Lr, Mag and angle attributes - do i have to make them as a character's attribute or game's? I can't make it working. :/

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @janis.piziks@gmail.com said:
    This is nightmare :/

    Thanks for the feedback.

    @janis.piziks@gmail.com said:
    About Lx, Ly, Lr, Mag and angle attributes - do i have to make them as a character's attribute or game's? I can't make it working. :/

    Check out my instructions above, it's clearly stated what needs to be done.

  • BaccardaBaccarda Member Posts: 122

    Sorry about that and i really appreciate your work. :)
    I did everything exactly as you wrote, but the collision character disappears when i'm trying to test it. :/ That's why i said that it is a nightmare. :/

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @janis.piziks@gmail.com said:
    . . . the collision character disappears when i'm trying to test it . . .

    Not enough information to proceed. I would need to be able to see all of the expressions - at the moment the ends are chopped off by the expression window - as well as all the rules for the Rock actor. Also the second to last Constrain behaviour needs to be constrain self.position.Y (rather than self.position.X)

  • BaccardaBaccarda Member Posts: 122

    I think that i should move on and continue with a plan B, because i think that it will cost me too much time to apply all those rules to 20 more objects like that and i think that it would be smarter. :)

    Socks, thank you for your time and patience. :)

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @janis.piziks@gmail.com said:
    I think that i should move on and continue with a plan B, because i think that it will cost me too much time to apply all those rules to 20 more objects like that and i think that it would be smarter. :)

    You don't need to apply the rules to 20, or more, objects, you only need 1 collision point actor.

    You place the rules (just 5 change attributes and 3 constrains) for the collision point actor in the main collision point actor and then just drag as many multiple copies as you need into the scene. That's all you have to do, everything else after that point is automated.

  • SocksSocks London, UK.Member Posts: 12,822

    @janis.piziks@gmail.com said:

    Attached is a little QuickTime movie - that shows you how straightforward the above method is to use.

  • BaccardaBaccarda Member Posts: 122

    Socks - u're GOD!

Sign In or Register to comment.