Actor around planet: wrong rotation / orbit starting point

zapposhzapposh Member Posts: 65
edited November -1 in Working with GS (Mac)
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

Comments

  • old_kipperold_kipper Member Posts: 1,420
    This is a bit beyond me but I did a figure of 8 example for someone and it divided the rotations into 4 sections for each circle. I am not sure it would work but if you could cant the path to tangent of the planet collision point it might. I am not sure how you would deal with it being joined not at a 1/4 point, but I will think about it if you think it would help.

    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
  • DrGlickertDrGlickert Member Posts: 1,135
    Are the planets rotating? The player might be starting at a point because the planets aren't rotating.

    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?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    look up my "Mr.Ninja" demo in the creator. I used some pretty tricky trig to solve this. I have to say it is my best coding yet! (not that that is saying much)
  • zapposhzapposh Member Posts: 65
    Thanks very much guys. for your input.

    @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
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    are you trying to do something like this? watch the video
    http://gamesalad.com/forums/topic.php?id=24356

    it took me a week to get the logic right
  • old_kipperold_kipper Member Posts: 1,420
    jonmulcahy said:
    are you trying to do something like this? watch the video
    http://gamesalad.com/forums/topic.php?id=24356

    it took me a week to get the logic right

    Respect!

    Kipper
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    zapposh said:

    @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

    I haven't noticed this actually. hmm...

    I'll have to look into it.
  • zapposhzapposh Member Posts: 65
    Hey found 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 :-) .
Sign In or Register to comment.