Atom.
As_Of_Latte
Member, BASIC Posts: 343
Haven't posted in the forums for a bit! Just looking for a little outside help with this one...
Would anyone know how to create a various number of atoms circling and constrained to the center actor? My goal is to have my actor spawn an atom type "shield" that wraps around him to protect him from collisions during gameplay.
Something similar to this. I'm not the best when it comes to cos/sin equations
Thanks in advance!
Comments
I picture it like
game.RingRotationAdjustment = 180 / game.TotalRings
self.Rotation = (self.RingID * game.RingRotationAdjustment)
You would need to start the ring IDs at 0, but it should work without overlap.
Like, in the case of the gif, you would have 4 rings.
45 = 180 / 4
Ring0 = 0 * 45 = 0
Ring1 = 1 * 45 = 45
Ring2 = 2 * 45 = 90
Ring3 = 3 * 45 = 135
@Moik Thanks for the quick response! This looks great, but I'm still somewhat of a GameSalad noobie and it's a little hard for me to follow
Would each ring be a different actor? Would you mind breaking this down a little further...?
Make a couple of game attributes . . . . 'angle' and 'radius' . . . + create a master electron actor . .
In the master electron place two constrains:
Constrain angle to vectorToAngle( self.Position.X -512, self.Position.Y -384)
Constrain radius to magnitude( self.Position.X -512, self.Position.Y -384)
Then add the oval path movement to this master electron with:
Constrain X position to 200 *cos( game.Time *100)+512
Constrain Y position to 60 *sin( game.Time *100)+384
. . . . . . . . .
Then create a series of further electron actors (as many as you like) with:
Constrain X position game.Radius *cos( game.Angle + self.Name )+512
Constrain Y position game.Radius *sin( game.Angle + self.Name )+384
For each angle offset simply change the name of the electron actor, so for your example (the GIF) there would be the master electron + 3 other electron actors named 45, 90 and 135. The name of the actor controls where it sits in the atom's shell.
@Socks - Doesn't that keep the atoms in sync, though?
Edit: Could be easily overcome by randomising which way round you put sin/cos in each electron, I guess.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support