Getting one actor to rotate around another - gears with teeth
![frankwashburn](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Hey all,
So this question was asked before quite some time ago, but I'm running into some problems and I was wondering if anyone had any insight into this.
So I'm trying to make a gear with teeth.
I have the rotating Gear axis, and he just rotates and as he does he contrains an attribute game.gear rotation to his own self rotation.
Then I have 4 teeth so far, each of which:
Constrain X position: (RadiusOfRotation)*cos((game.time+OFFSET)*GearAxisRotationSpeed)+GearAxisX
Constrain Y Position: (RadiusOfRotation)*sin((game.time+OFFSET)*GearAxisRotationSpeed)+GearAxisY
and Constrain Rotation to: Game.gearrotation + ANGLEOFFSET.
ANGLEOFFSET I have down correctly - each of the 4 teeth need to have a different ANGLEOFFSET: 0, 90, 180, 270.
However, the time OFFSET is throwing me off.
QUESTION:
What units are the speed of the "Rotate" rule? Degrees per second?
If so, then what I have been doing is thus:
If the gear axis rotates at 20 degrees per second, then that means that it takes 16 seconds for a full rotation. Then a quarter rotation should be a length of 4 seconds.
That means for GearTooth1, OFFSET should be 4 seconds.
GearTooth2 OFFSET should be 8 seconds
GearTooth3 OFFSET = 12 seconds
GearTooth4 OFFSET = either 0 or 16 seconds.
However, if I do this, then GearTooth1 moves ever-so-slightly not aligned with the proper axis of rotation, GearTooth2 is more misaligned, GearTooth3 even MORE misaligned, and GearTooth4 the most misaligned. There's some problem with the OFFSET value that's throwing them out of whack.
Right now my GearAxis is a square. Instead of each GearTooth coming out of the middle of the side of the square, the first one comes out slightly not-in-the middle and the last one is almost flush with the corner!! It looks awful, and it's clear that there's something slightly wrong with my math. Any ideas?
So this question was asked before quite some time ago, but I'm running into some problems and I was wondering if anyone had any insight into this.
So I'm trying to make a gear with teeth.
I have the rotating Gear axis, and he just rotates and as he does he contrains an attribute game.gear rotation to his own self rotation.
Then I have 4 teeth so far, each of which:
Constrain X position: (RadiusOfRotation)*cos((game.time+OFFSET)*GearAxisRotationSpeed)+GearAxisX
Constrain Y Position: (RadiusOfRotation)*sin((game.time+OFFSET)*GearAxisRotationSpeed)+GearAxisY
and Constrain Rotation to: Game.gearrotation + ANGLEOFFSET.
ANGLEOFFSET I have down correctly - each of the 4 teeth need to have a different ANGLEOFFSET: 0, 90, 180, 270.
However, the time OFFSET is throwing me off.
QUESTION:
What units are the speed of the "Rotate" rule? Degrees per second?
If so, then what I have been doing is thus:
If the gear axis rotates at 20 degrees per second, then that means that it takes 16 seconds for a full rotation. Then a quarter rotation should be a length of 4 seconds.
That means for GearTooth1, OFFSET should be 4 seconds.
GearTooth2 OFFSET should be 8 seconds
GearTooth3 OFFSET = 12 seconds
GearTooth4 OFFSET = either 0 or 16 seconds.
However, if I do this, then GearTooth1 moves ever-so-slightly not aligned with the proper axis of rotation, GearTooth2 is more misaligned, GearTooth3 even MORE misaligned, and GearTooth4 the most misaligned. There's some problem with the OFFSET value that's throwing them out of whack.
Right now my GearAxis is a square. Instead of each GearTooth coming out of the middle of the side of the square, the first one comes out slightly not-in-the middle and the last one is almost flush with the corner!! It looks awful, and it's clear that there's something slightly wrong with my math. Any ideas?
Answers
Of course, if this were another engine, I could make a 3D mesh of any shape and assign collision properties according to that specific shape, but yeah, I'm trying to work around Gamesalad's rectangular/circular collision forms.
I wanted to make sure I wasn't lying, so I made a demo project, you probably don't need it but here it is:
http://www.gamefront.com/files/21823328/teeth.gameproj.zip