Need an actor to follow AND rotate around another actor...

Hey guys. This is my first time posting to the forums. I've done some digging, both here and on the net, and have found some info, but none of it seems to exactly fit the problem I am having. Here's the deal:

I'm making a little game with a spaceship. This ship has a front, left, and right shield. At the start of the game, the ship is put into forward motion. You can't slow down and you can't stop, but you CAN turn left and right.

My problem has to do with what happens as the ship is turning. The actor I'm using for the front shield should always be in front of the ship (at the top of the ship if ship is moving up the screen). When I start turning the ship, the shield starts turning, as it should, but it's not correctly following the ship actor.

I've seen all the posts about getting actors to follow other actors, but those all seem to deal with the actor making a continual same direction movement. If my ship turns completely around, so it's now flying down the screen, my front shield should now be BELOW the ship, instead of ABOVE the ship.

I've been playing with storing the ship's X and Y and then constraining the X/Y's of the shields to the other actors, and that seems to work for keeping the shield actors WITH the ship, and I've also played with using the Rotate attribute to rotate the shields with the ship, and that also seems to SORT of work, but I need a way to keep all the actors locked in position around the ship, so if the central ship actor turns, all the other actors also turn/orbit AROUND the central point of the ship actor.

I've seen the comments about getting an actor to orbit another actor, but that seems to be an automatic movement, as in planets orbiting a sun, but I want the movement constrained to the central actor, like a geostationary satellite moves with the earth as it rotates, etc.

Any help would be appreciated. Oh, and as the category confirms, I'm trying to do this using the WINDOWS version of GS.

Dave

Best Answers

  • SocksSocks London, UK.Posts: 12,822
    edited December 2014 Accepted Answer

    I made this highly accomplished technical drawing for you . . .

    Here the green dot is being constrained to the wing of the space ship, let's say we want it 44 pixels from the centre of the ship and at about 65° . . . which should look something like this:

    Constrain x to 44 *cos(ship rotation +65)+ship x

    Constrain y to 44 *sin(ship rotation +65)+ship y

  • SocksSocks London, UK.Posts: 12,822
    Accepted Answer

    Also . . . . I made this project specifically for doing what you need doing here . . .

    http://forums.gamesalad.com/discussion/62202/linkmachine

Answers

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2014

    Shield

    Constrain x to AAA *cos(ship rotation +BBB)+ship x

    Constrain y to AAA *sin(ship rotation +BBB)+ship y

    Constrain rotation to ship rotation

    AAA=distance from ship

    BBB=angle offset

  • dotorandotoran Member Posts: 8

    Socks,

    The AAA is the X/Y distance of the shield at the beginning, when the shield is right in front of the ship, right?

    What's the BBB? Where do I get that value?

    I was already constraining the ShipR (rotation) along with the X/Y.

    Thanks,

    Dave

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2014

    @dotoran said:
    The AAA is the X/Y distance of the shield at the beginning, when the shield is right in front of the ship, right?

    Not quite, AAA is not really the X/Y distance, these are radial co-ordinates, so it is simply the radius, imagine we are drawing a circle around your ship, AAA is the size of the circle.

    @dotoran said:
    What's the BBB? Where do I get that value?

    BBB is the offset of the angle cos and sin are working on, going back to imaging we are drawing a circle around the ship . . . .

    The ship is pointed to 0°, which is right (3'0'clock) . . . so for something to be positioned at the ship's nose the offset would be 0° (no offset), something positioned on the lefthand side of the ship would be 90°, 180° for the rear and 270° for the right hand side.

    So, for example, an object constrained to 112 pixels off the righthand wing of the ship:

    Constrain x to 112 *cos(ship rotation +90)+ship x

    Constrain y to 112 *sin(ship rotation +90)+ship y

    Constrain rotation to ship rotation

  • dotorandotoran Member Posts: 8

    Socks,

    You TRULY ARE AWESOME!

    Both your explanation, your incredibly accomplished technical drawings, and that awesome example project and video were EXACTLY what I was looking for.

    It's funny, because my artistic skills really stink. Your tech sketch version ship is only about 1000% better than the ship I'm using! ;-)

    Now I'm ready to have even more fun with this software!

    Thanks again!

    Dave Weeks

  • SocksSocks London, UK.Member Posts: 12,822

    @dotoran said:
    It's funny, because my artistic skills really stink. Your tech sketch version ship is only about 1000% better than the ship I'm using! ;-)

    Lol ! : )

Sign In or Register to comment.