Actor around planet: wrong rotation / orbit starting point
Hi,
After literally loosing days spent on trial and error I'm posting my problem. I also went through many posts here on the subject, but found no straight out solution.
I have an actor floating through space, and several planets on screen.
On collision, the actor rotates/orbits around the collided planet. On mouse down, the actor leaves orbit and floats again until reaching the next planet, and so on.
All this works fine! The only problem is that the rotation / orbit of the actor around the planet starts anywhere,and not at the collision spot as it needs to be.
I've tried things like
constrain self.X to ( game.PlanetRadius + game.ActorRadius )*cos( game.PlanetRotation )+ game.PlanetX
and sin for the Y.
or
constrain self.X to ( game.PlanetRadius + game.AlienRadius )*cos( self.Time * 20 %360)+ game.PlanetX
and then tried to extract the VectorToAngle between the Actor and the Planet (Angle Value from a Constrain Attribute) but somehow no matter how or where I insert this value, things go wrong. Tried dozens of other approaches without any success.
Help here would be most welcome please.
Thank you
After literally loosing days spent on trial and error I'm posting my problem. I also went through many posts here on the subject, but found no straight out solution.
I have an actor floating through space, and several planets on screen.
On collision, the actor rotates/orbits around the collided planet. On mouse down, the actor leaves orbit and floats again until reaching the next planet, and so on.
All this works fine! The only problem is that the rotation / orbit of the actor around the planet starts anywhere,and not at the collision spot as it needs to be.
I've tried things like
constrain self.X to ( game.PlanetRadius + game.ActorRadius )*cos( game.PlanetRotation )+ game.PlanetX
and sin for the Y.
or
constrain self.X to ( game.PlanetRadius + game.AlienRadius )*cos( self.Time * 20 %360)+ game.PlanetX
and then tried to extract the VectorToAngle between the Actor and the Planet (Angle Value from a Constrain Attribute) but somehow no matter how or where I insert this value, things go wrong. Tried dozens of other approaches without any success.
Help here would be most welcome please.
Thank you
Comments
you can find my figure of 8 by searching in the GS new project browser under 'figure'. I did the movement with interpolates with ease in and out to envelope the 2 values which I was surprised at how well it worked.
hope that give some help.
kipper
If they aren't then you could either 1) make them rotate, or 2) create invisible actors that rotate
Then on the actor, have the actor "orbit" around the planets based on their rotation.
**
Make a real-attribute (or an angle attribute) - game.PlanetRot
Then, when player collides with the planet then change attribute; PlanetRot to self.rotation
Have the actor stick to the game.PlanetRot
Have you tried this?
@old_kipper : I will check out our scene this morning, thanks. Could provide some interesting new approach
@DrGlickert : When the actor hits a planet, the planet rotates, and the actors rotates with the planet. Like you mentioned, I have a game.PlanetRot attribute. Then for the actor I did the following constraint (when overlapping or colliding with planet):
self.X to ( game.PlanetRadius + game.ActorRadius )*cos( game.PlanetRot )+ game.PlanetX
and sin for the Y.
So the rotation and speed work fine, as well as "releasing" the actor back into space.
The planet always starts its rotation from a 0 angle. Is that the problem?
@scitunes : yes thanks, I loaded up your scene which is in fact quite similar to what I'm trying to set up. Interesting approach to split up the planets into quadrans and start the angle rotation from there. What bugs me a little is although it works fine for small surfaces, on large ones, it lacks precision where the rotation will start in the proper quarter, but not in the exact collision spot, creating a "jitter". Have you also noticed that when you speed up the jumps and go on for a while jumping from disc to disc the jump angle will turn out to be wrong? Wonder what provokes that? Did you notice this problem?
Catch you later
http://gamesalad.com/forums/topic.php?id=24356
it took me a week to get the logic right
Kipper
I'll have to look into it.
Thanks scitunes for your base. I used it for starters, and simplified it by removing the quadrant system, and using the VectorToAngle between the Actor and the Planet as the rotation start angle of the planet.
game.PlanetAngle is constrained to (planet.selfRot + startAngle)
Then, if we constrain de X of the Actor to
( game.PlanetRadius + game.AlienRadius )*cos( game.PlanetAngle )+ game.PlanetX
it works!
Actually, I think that the bad angle jumping off the planets is not due to your code, which looks flawless, I think it's due to processing time in gamesalad when things move too fast, as the registered "jump" does not happen at the time of "touch" or "mouse down". Made several testes and it seems to be the case.
@jonmulcahy
That is more or less what I'm trying to do! I must saw I'm blown away by your game! Lot's of love, sweat and effort went in to that, and I agree with old_kipper: it's a winner! I'm off to buy it myself as a matter of fact :-) .