Need some math Help.
The_Gamesalad_Guru
Member Posts: 9,922
I have an actor that moves freely in a circle controlled by the accelerometer. Think a marble rolling around in a tire held by gravity. I'd like to constrain some other actors to mirror it's movement. These actors don't need physics just a straight mirror constrain set to a distance away. Think objects moving around a circle placed at different spots of the circle but taking their movements cues from one actor in sync. @RThurman @Socks @LumpApps
Comments
@The_Gamesalad_Guru, can you not just constrain as usual but add an X or Y offset to the second actor?
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
I think what he means they are in the same 'tire,' but at a different part of it?
@The_Gamesalad_Guru?
I can think of an easy way to do a mirror image, but angles other than 180 will be more difficult.
Are you using any math for controlling the main actor, or is it simply accelerometer and physics?
No the main actor is free flowing. I'm using the accelerometer to control gravity and the actor is suspended inside a walls shaped in a circle. so it works like a marble in a hula hoop. The other actors need to mirror it's movement 360 degrees. I'm not good with vector to angle math.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Same thing would apply, add an offset for positioning, some multiplication if the circle is bigger or smaller.
Constrain self.positionX to (game.otherX*0.5)+300
will offset the position and halve the radius.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
That is not working the other actor just holds it's distance but doesn't move
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Maybe this visual will help
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@The_Gamesalad_Guru , ok, understood, here is a project
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
That works Awesome! One quick question. I imagine if I want the second actors position to be different on the circle would I add an offset to "actual" or the "+Gamecenter"? @Hopscotch
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Different in what way?
You can just add an offset to the calculation of the mirrored actor if it is just displaced in some direction. If the radius should be different then it is a bit more involved. @The_Gamesalad_Guru
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Nope the radiant is the same just ghosting the position of the main actor so another actor mirrors in a different place in the same orbit.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Are you implying more a shift in time as opposed to 1 to 1 mirroring? That sound like a job for tables.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
No just more electrons like this. I want to keep adding electrons and have them move with the main actor but on an offset
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@Hopscotch -- very nice implementation. But as I mentioned, while it is straightforward with 180 degrees (mirror), it is more complicated if the offset is not 180, but, say, 37 degrees.
@pHghost, @The_Gamesalad_Guru , but doable. I'll tinker...
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
You're the best. I owe you!
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Here's a template with angle offset, but it might not be easy to figure out how it works. Let me know if you want me to clean it up or explain it.
https://www.dropbox.com/s/4omvtjsnh8arz3o/GhostingWithAngleOffset.zip?dl=0
@Manto1, thanks, problem is first getting the at-the-moment radius and angle of the main actor, since it moves freely. Then calculate the position, including angular offset, of the mirrored actors.
Got to pop out for an hour, will look at it after that if no one picked it up by then.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Hopscotch ah, I missed the radius part. But couldn't you just use Pythagorean theorem for it? Magnitude(actor.x-centerx, actor.y-centery)? Or am I missing something (again)?
Thanks will check it out.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Here's another version where you can move the actor freely. The follower actors calculate the radius of the main actor and move based on that.
https://www.dropbox.com/s/mzx2mv9tbf1z1k2/GhostingWithAngleOffsetMovingFreely.zip?dl=0
Good one, @Manto1! I think that's exactly it, @The_Gamesalad_Guru, correct?
Just finished doing the math on paper, and was about to take it over to GS, you beat me to it!
@The_Gamesalad_Guru -- Found this, a concise explanation of what is what in the calculation (and a good guide for arranging everything the way you need it to be in your own game):
http://gamedev.stackexchange.com/questions/18340/get-position-of-point-on-circumference-of-circle-given-an-angle
Super @Manto1!
Snap! Had the same idea.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Thanks for the handy link @pHghost!
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
@Manto1 -- Great example! Very useful.
Watching the Apple event will try it out after. Thanks for all the help you math gurus!
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@Manto1 That is some slick $hit!
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
You can just measure the angle of the main ball from the centre of the circle and also the distance of the main ball from the centre of the circle - then constrain all the other balls to these values . . . but add an offset to their angle.
Example - you can pick up the white dot and drop it where you like, all the other dots are constrained to it, with offsets.
Link: https://www.mediafire.com/?u821u1m0vd9jg63