interpolate actors to orbit each other

slevslev Member Posts: 99
edited November -1 in Working with GS (Mac)
im making a space based game and i want objects to hit each other and when they do orbit one another i want them to have a geostationary orbit (as the main object rotates the smaller one orbits around it in the same place).

is this possable to do with interpolateing the smaller objects possition in relation to the large ones rotation??

cheers

Comments

  • slevslev Member Posts: 99
    bump?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    youll need to use sin and cos. Youll also need to make 2 real attributes call them planetx and planety and in the planet you want to orbit around change attriubtes planet x and y to self position x and y.

    then in the actor you want to orbit around in the circle constrain

    self.Position.X = 120*cos(self.Time*100%360)+planetX

    self.Position.Y = 120*sin(self.Time*100%360)+planetY

    planet x and y at the end of those expressions are the 2 real attributes you made, and the 120 represents the distance from the center planet your orbiting around
  • Rob2Rob2 Member Posts: 2,402
    I did you a project you can download at the end of the other thread :)
    http://gamesalad.com/forums/topic.php?id=20867
  • matthowarthmatthowarth Member Posts: 76
    hi guys,

    thanks for explaining this. Rob, am I correct in thinking your project is for a web app, rather than an iphone app? It appears to have a really useful ability to use the attributes of other actors, that I can't find in my project.

    cheers

    Matt
  • ckck Member Posts: 224
    I think planetX and planetY are variables, constrained by self.Planet.X and self.Planet.Y of the actor at the centre of the orbit
  • matthowarthmatthowarth Member Posts: 76
    yes, I think you're right, but in my iphone game there isn't an otion to constrain directly to another actor, you need a game attribute which the target actor changes and the child actor is constrained to. Rob's project has a thing called "scene" which I haven't seen before. My project has options "game" "devices" and "self".

    Am I missing something?
  • Rob2Rob2 Member Posts: 2,402
    Matt

    Once an actor is placed in the scene (and unlocked) it can have direct access to all the events and variables (attributes in GS) of the scene/game/whole shooting match!!

    Simply drag an actor to the scene window, double click then click to unlock and you will find the attribute browser now has a new entry 'current scene' from where you can drill down to all sorts of stuff and directly access other actors attributes.
  • matthowarthmatthowarth Member Posts: 76
    thanks very much Rob, this opens all manner of possibilities!!!

    cheers

    Matt
Sign In or Register to comment.