Constrain a line to an actor question...

delorianhayzedelorianhayze Member Posts: 55
edited August 2012 in Working with GS (Mac)
Hey all.
I've been looking all over for this one (even though I'm sure it's out there somewhere)-
I need a basic line to be able to constrain and/or move with my actor from a center point. Think the slingshot ropes in angry birds. I'm sure there's a million templates out there but since they're down it's hard to get an answer for this one. Any help would be appreciated.
Thanks!

Comments

  • wij_manwij_man Member Posts: 66
    edited August 2012
    Have two blocks (make them tiiiiiiny): they will be your elastic
    Have two other blocks, they will be your anchor points (set alpha to 0)
    Anchor points - add global variable (mine are scene.Connector1/2.Position.X/Y)
    More global variables game.BlockX/Y for me (the thing you are throwing)

    Elastic on the right:
    self.width = magnitude( scene.Connector1.Position.X - game.BlockX , scene.Connector1.Position.Y - game.BlockY )
    self.rotation = vectorToAngle( game.BlockX - scene.Connector1.Position.X , game.BlockY - scene.Connector2.Position.Y )
    self.positionY = game.BlockX +( scene.Connector1.Position.X - game.BlockX )/2
    self.position.X = game.BirdY +( scene.Connector1.Position.Y - game.BlockY )/2

    Elastic on the left:
    Do all the same as the above but with scene.Connector2

    In the above you make some anchor points which hold one side of each "bit" of elastic. You then attach the other side to the bird. Then set the rotation of the elastic. Then the width (really the length as you would think in the real world).

    I wrote the above in no particular order, just as it came to me, also it's 02:15, so no promises that any of the above is in any way correct! ;-)

    Also - "slingshot ropes" is what made me want to help... I did something like this the other day and I couldn't find anything to help me so I player with it all day till I got it right. It seemed to work, but once I did it I deleted it and carried on with my own game. It was just a distraction to save me from thinking about vector addition...

    Thanks

    p.s. I'm going around answering questions so that the people who actually know what they're doing will take a few minutes to answer mine! I'm totally stuck on a few things and it's driving me nuts!
  • delorianhayzedelorianhayze Member Posts: 55
    edited August 2012
    wijman, THANKS! I tried this BTW and it didn't work out 100%. It appears that it might work but something appears a bit off. For your "Elastic On The Right" section I used "constrain" (I think that's what you wanted). But when I try it, the "rope" is going in the opposite direction and not connecting to the slingshot. When you get a chance, if you can, can you please let me know what I might be doing wrong. Thanks a million!
  • wij_manwij_man Member Posts: 66
    Hi,

    No problem. Any chance you can upload your project somewhere? Also, all three are constrains - Sorry, forgot to mention that, but it was very late! :) Also in the last self.Position.X it should have been BlockY - I wrote BirdY because I was thinking about angry birds! lol
Sign In or Register to comment.