Rotation problem

tim13211tim13211 Member Posts: 87
edited November -1 in Working with GS (Mac)
I have square actors positioned in different parts of the scene. I need them to rotate, not from their center point but the center point of the screen. How can I accomplish this?

Example:

image

Comments

  • m456arcusm456arcus Member Posts: 189
    Funny, I'm in the exact same situation. Any help?
  • Rob2Rob2 Member Posts: 2,402
    x=distance*(cos(angle))
    y=distance*(sin(angle))

    is the formula that you need where x,y is the centre point of your blue squares and distance is the distance to your red center. So for every point around your black arrow circle you calculate a new xy based on a changing angle.

    recently covered here :-
    http://gamesalad.com/forums/topic.php?id=20867

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

    this diagram says it all :)

    http://gamesalad.com/forums/topic.php?id=19860#post-151044
  • m456arcusm456arcus Member Posts: 189
    Great, thanks thats a huge help. I'll go try it now then...
  • m456arcusm456arcus Member Posts: 189
    Wait... so if these constraints go in the blue actors, is x and y the red or the blue self.position? And distance is just the radius of the constraining circle then... I'll have another go at it, hold on...

    Tim, have you got yours working?
  • tim13211tim13211 Member Posts: 87
    m456arcus said:
    Tim, have you got yours working?

    Ish

    I'm confused on what the distance is supposed to be and the angle.
    I probably didnt set it up right but what I have is-

    I set up a game attribute, an angle, called game.rotation_angle

    Red actor- contrain game.rotation to self.rotation

    blue actor- constrain self.position.X to 25*(cos( game.rotation_angle ))
    constrain self.position.Y to 25*(sin( game.rotation_angle ))

    The problem is that the blue actor is rotating around X-0 and Y-0 of the screen (bottom left)

    @Rob2 what am I doing wrong?
  • m456arcusm456arcus Member Posts: 189
    tim13211 said:
    I set up a game attribute, an angle, called game.rotation_angle

    Same here.
    tim13211 said:
    The problem is that the blue actor is rotating around X-0 and Y-0 of the screen (bottom left)

    I think the problem here is that you're not telling the blues where the centre point is... It has no idea where to go so it defaults to 0,0... Is that anywhere near correct Rob?

    I've got the same thing now. What is the proper way to include the player's x and y?
  • m456arcusm456arcus Member Posts: 189
    GASP! I think I got it! And it was really very simple, too. I took my 2 constrain behaviours, and added playerX to the X one and playerY to the Y one. Seems to work for now.
  • tim13211tim13211 Member Posts: 87
    m456arcus said:
    What is the proper way to include the player's x and y?

    Yes

    How can I set the center point of rotation to the red actor. And also how can I maintain the blue actors current position before rotating, because right now all the blue squares I have on the scene are on top of each other.
  • tim13211tim13211 Member Posts: 87
    m456arcus said:
    GASP! I think I got it! And it was really very simple, too. I took my 2 constrain behaviours, and added playerX to the X one and playerY to the Y one. Seems to work for now.

    Can you tell me what you did? :)

    I cant figure it out...
  • m456arcusm456arcus Member Posts: 189
    Just do what I said for the x and y, add them to the end.
    image

    For them to maintain position before rotating, just have them only constrain using that formula when the event that causes them to rotate is true.

    In other news, my attempts have failed and I've celebrated too early. It's more complicated because in mine, its a tank, which moves and rotates. I constrained the turret rotation to the tanks, and it worked. but as soon as I want to turn the turret, it all falls apart, unfortunately.

    Since Gamesalad is a physics-centered program, wouldn't it make sense to include pivot points and that type of stuff?
  • tim13211tim13211 Member Posts: 87
    there got to be something we are missing.

    for me i need the actors to rotate left (around the center or the scene) when the left key is pressed

    my whole game depends on this so if it doesnt work i cant make the game :(
  • m456arcusm456arcus Member Posts: 189
    I updated my post, have a look at the picture. And for the rotate left on command thing, I have no clue.

    Could someone chime in before my head explodes again?
  • Rob2Rob2 Member Posts: 2,402
    whats -23?
  • m456arcusm456arcus Member Posts: 189
    imageimage
    The red O is the center of the actor.

    Ok, -23 is the distance between the middle of the turret and the middle of the turret ring, where the rotation point should be.
    Note that in these, the rotation of the turret is the same as the rotation of the hull at all times. Like I said, when I want the turret to turn independently, it screws up big time.
  • tim13211tim13211 Member Posts: 87
    whats game.playerX?
  • m456arcusm456arcus Member Posts: 189
    playerX is the hull of the tank, the main player actor. I realize that my game is different than yours and maybe the same solution might not apply for both of us, your issue seems a touch easier. Have you made any progress yet?
  • tim13211tim13211 Member Posts: 87
    unfortunately, no. This game shows what I am trying to achieve:

    http://www.coolmath-games.com/0-rotate-and-roll/index.html
  • Rob2Rob2 Member Posts: 2,402
    whats the bug ?
  • Rob2Rob2 Member Posts: 2,402
    would be nice to know if there is a specific bug you are aware of :)
  • Rob2Rob2 Member Posts: 2,402
    Thanks very much for that explanation, I hadn't got to that bit ! literally just got my pivot function sussed so I can move it anywhere and then the planks obey and was just about to put my balls on the table so to speak!! So I will see. Thanks again for the detail, good to know.
  • Rob2Rob2 Member Posts: 2,402
    I remember similar problems with spinning planks before ? you solved it with some clever directional vector..anyway, will post findings and maybe youtube.
  • Rob2Rob2 Member Posts: 2,402
    Yep this is a tragedy :) All works nicely but your ball or whatever character you choose sinks link a knife into butter, or pings off like a madman. It seems all collisions with actors whose xy is constrained are not going to work properly. I'm surprised this has not caused more problems for people before.
  • m456arcusm456arcus Member Posts: 189
    Ya, this really sucks. If a head chef is paying any attention (I'm sure you are), all these physics problems should really be a top priority. They should have the same ease of use as everything else Gamesalad can do, too.
    As of now, there is no way I can finish my game. Which really is disappointing.
  • tim13211tim13211 Member Posts: 87
    tshirtbooth said:
    I have been working on it for awhile now but there is a bug in GS that i need to be fixed first



    cheers

    This is EXACTLY what i need!!! I would very much appreciate a tutorial, or even a picture so I can get an idea of the expression
Sign In or Register to comment.