Constrain object to a rotating object
Baccarda
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
Use this, it will do all the calculations for you:
http://forums.gamesalad.com/discussion/75220/fast-constrain-linkmachine-v2
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.
@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
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.
Thanks for the feedback.
Check out my instructions above, it's clearly stated what needs to be done.
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.
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)
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.
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.
Attached is a little QuickTime movie - that shows you how straightforward the above method is to use.
Socks - u're GOD!