Calculating Rotation Relative to a Fixed Point?

ShanghaiShanghai Member Posts: 11
edited November -1 in Working with GS (Mac)
Hey all! This is my first time on the forums, and I'm new to GameSalad (though I have previous coding experience).
I'm wondering if I can get multiple actors to rotate around the center of my scene. I want them to move in relation to the center, acting like something that tries to move forward but is tethered to a pole; the rope forces the thing to rotate around the pole it's tethered to. I'm trying to figure out whether I need to do some calculations for this, or if there's a built-in behavior I'm just not seeing. If it requires calculations, somebody's gonna have to help me (read: do them all for me).

Am I making myself clear at all? Regardless of whether or not I get any help, thanks for reading.

Comments

  • UtopianGamesUtopianGames Member Posts: 5,692
    Something like this?



    You will need to use cos and sin.

    Darren.
  • ShanghaiShanghai Member Posts: 11
    That looks pretty good. I'll have to edit it to my own purposes a bit to get it to work for me. Can I download the code by any chance?

    While I'm at it, is there a way to have music continue from scene to scene? As is, each level of my game is a different scene, and the music restarts each scene.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    brendanwalsh said:
    That looks pretty good. I'll have to edit it to my own purposes a bit to get it to work for me. Can I download the code by any chance?

    While I'm at it, is there a way to have music continue from scene to scene? As is, each level of my game is a different scene, and the music restarts each scene.

    Im pretty sure thats a menu template he Sells at www.deepblueapps.com
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    tsb can u help with this

    http://gamesalad.com/forums/topic.php?id=33949

    the question is in the forum, im not sure if gs is capabile of a mechanic i need to finish my game
  • morphinegamingmachinemorphinegamingmachine Member, PRO Posts: 449
    also, i'm downloading that template u showed, looks awesome
  • ShanghaiShanghai Member Posts: 11
    Wow, that's perfect! It barely even needs reworking. Thanks, I'll make sure to credit you when I'm done with the game.
  • ShanghaiShanghai Member Posts: 11
    After attempting to implement the code, this is the closest I got. The platforms rotate, but they don't align to the edges of the square.
  • ShanghaiShanghai Member Posts: 11
    I guess I wasn't clear about what I meant. I'm looking to have the entire level rotate around the center, walls and all. As is I only put in the code for the floors and roofs, but they are still not behaving as expected (they are pointing the right direction, but their positions are not keeping them aligned with the edge of the square background).
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Based upon your video -- I think I see what you are after.

    This will all be much easier once joints are implemented. But in the meantime I created a template where the walls rotate around and move in relation to a grey box. It requires a bit of trig but the formulas can be readily cut and pasted into your game.

    Give it a try:
    http://www.speedyshare.com/files/31031054/RotationRelToFixedPoint.zip

    Hope this helps!
  • ShanghaiShanghai Member Posts: 11
    Wow, RThurman! You're like a mind-reader who can do trig. That's exactly what I needed, and it works perfectly with no modification. You're awesome! The best I can do right now is credit you for the code, but eventually I'll thank you in a more substantial way.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    brendanwalsh said:
    That's exactly what I needed, and it works perfectly with no modification.

    Glad it worked for you. Don't worry about credits or anything. It was just a five-minute modification of a demo that's already on GameSalad Creator. (The one called "Off-Center Rotation")
  • ShanghaiShanghai Member Posts: 11
    SUPER TOPIC REVIVAL GO!


    The rotation's been working great, but there's one problem. I cannot rotate the stage twice in the same level. The first time, everything follows fine, but the second time, the dynamic actors (objects effected by physics, like the player) have their positions messed up. I've deduced that the problem is with the rotation attribute, because the rotation does not change based on the positions of the objects, causing them to revert to positions near where they began rotating last time.

    Thoughts?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    I'm not quite sure what you are asking. The video looks like everything is working. I don't see what you are referring to. (Perhaps the video does not show the problem?)

    Nice concept for a game though. I'm working on a similar idea -- but just for learning GameSalad -- not necessarily anything commercial.
  • ShanghaiShanghai Member Posts: 11
    I'll post a video of the problem tomorrow, that was just showing what does work (more than I expected).
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Here is an example of a slightly different way of doing things. The behaviors are cleaner and get rid of the rotation issue I think you were describing. You rotate the box by moving the mouse (down) along the x axis. (But that can be changed easily.) Everything rotates around the tiny grey box. (Which can be repositioned anywhere.)

    http://speedy.sh/TWXqC/boxRoll.zip
  • ShanghaiShanghai Member Posts: 11
    Here's a video of the problem.

    I haven't had a chance to get a look at what you just posted, I'll see how it goes.
Sign In or Register to comment.