Rotations and expressions

rebzonerebzone Member Posts: 25
edited March 2012 in Working with GS (Mac)
Hi everyone,
does someone know if there's a way not to "invert" x and y axis when rotating an actor?
I mean, if I rotate my actor, i.e. 90 degrees, if I try to get self.position.X and Y, I get the correct ones, but if I have to make an expression, it works as x and y axis are "swapped" (depending on the rotation degree). So, if I try something like position.X = position.X + 40, it works while at 0 degrees, but if I want it to work at 90 degrees, I need to use the Y axis.
It's really confusing when using attributes and rules, so, is there a way to keep x and y axis in place for expressions even when rotating?

Comments

  • poopdecksweeperpoopdecksweeper Member Posts: 180
    edited March 2012
    try to use if self.roation = (whatever) then scene.autorotate.portrait to true.
  • rebzonerebzone Member Posts: 25
    edited March 2012
    ummm...I don't think I get the point... I can't find how to access the scene.autorotate.portrait attribute from the actor... I tried to set it manually, but nothing changes: isn't this attribute for the position I hold the iPhone?

    ...by the way, I used the downloadable example in this thread: http://forums.gamesalad.com/discussion/38105
    ...starting from that, I'm trying to add some rules to the square actor, but, as I said, it's a mess with x and y axis :(
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    Yes but I figured that if you made an attribute that changed upon actor rotation to (min=0, max=360) then autorotate phone to (x or y) and this will turn your x and y attribute without changing the screen. idk, just a shot. I have a hard time with stuff like that too. I think I need to take a few more college math classes.
  • MotherHooseMotherHoose Member Posts: 2,456
    edited March 2012
    Inspector    |Scene)    Atributes    Autorotate for above

    ====Or:

    Rule: When (Any)
    Attribute: self.Rotation =0º
    Attribute: self.Rotation =180º
    --do things with X
    Otherwise:
    --do things with Y

    @};- MH
  • rebzonerebzone Member Posts: 25
    so, you mean that I have to create 2 sets of rules every time, depending on the effective rotation degrees?
  • CloudsClouds Member Posts: 1,599
    Hi everyone,
    does someone know if there's a way not to "invert" x and y axis when rotating an actor?
    I mean, if I rotate my actor, i.e. 90 degrees, if I try to get self.position.X and Y, I get the correct ones, but if I have to make an expression, it works as x and y axis are "swapped" (depending on the rotation degree). So, if I try something like position.X = position.X + 40, it works while at 0 degrees, but if I want it to work at 90 degrees, I need to use the Y axis.
    It's really confusing when using attributes and rules, so, is there a way to keep x and y axis in place for expressions even when rotating?



    Gimbal lock !!!

    Maybe constrain the object that rotates to a 'null' object - and impose your X + Y movements on that 'null' object.
  • Rob2Rob2 Member Posts: 2,402
    Positions in the expression editor are always relative to the scene maybe one day we will get a local axis option. If you want to effect the X and Y position of an actor relative to its local axis you can use the move/move to and other behaviours which have a 'Relative to:' option.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited March 2012
    @rebzone

    That particular demonstration was to show how get an actor to 'lock on' to another actor and keep the same relationships between both actors. (It was to make them act as if they were welded together.) So to use that demo for another purpose might not be the best way to go.

    As Rob2 wrote, x,y positions are relative to the scene. It is as if you need to look at things from the third-person perspective, instead of first person (if that makes any sense).

    Perhaps it would be helpful for you to just move the actor to the proper x,y coordinates first, and then rotate it to the proper angle after it is in position. (When done at the proper speed, it looks like a smooth animation.)

    Hope this helps!
    RThurman
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited March 2012
    @rebzone

    Its been a couple hours since my previous post. I've thought about this a little, and perhaps you really do want to keep the two actors welded together, but just change the position of the square a little. In that case, you can use the demo but you would need to modify the offsetX and offsetY attributes in the square actor. So in the square's first two change attribute behaviors it would look like this:

    Change Attribute: self.offsetX To: game.RectangleX - self.Position.Y + (Whatever new calculations you need)
    Change Attribute: self.offsetY To: game.RectangleY - self.Position.Y + (Whatever new calculations you need)

    Hope this helps!
    RThurman
  • rebzonerebzone Member Posts: 25
    so, first of all, thanks everyone for the answers...
    I try to be more specific (maybe my english is not so good :P)
    @Rob2
    I don't want a local axis option...that's exactly the point... the problem is that every expression I'm trying to use is as it is relative to the rotation... I mean, if I want to make a move to +40 on x axis (relative to actor), when I'm at 0 degrees it works, but when I'm at 90 degrees it doesn't work, because after the rotation it seems to have inverted the x axis with the y one.

    @RThurman
    Actually I'm trying to reproduce the second behavior you described. What I want is a sort of an empty box where things happen inside...take a look at Rolling Kongs gameplay... the base idea is more or less the same.
    To achieve continuous locking between the box and the actors inside I used these behaviours:

    boxRotation angle = 0
    Change attribute: self.offsetX To game.boxX - self.Position.X
    Change attribute: self.offsetY To game.boxY - self.Position.Y

    boxRotation angle = 90
    Change attribute: self.offsetX To game.boxY - self.Position.Y
    Change attribute: self.offsetY To -(game.boxX - self.Position.X)

    boxRotation angle = 180
    Change attribute: self.offsetX To -(game.boxX - self.Position.X)
    Change attribute: self.offsetY To -(game.boxY - self.Position.Y)

    boxRotation angle = 270
    Change attribute: self.offsetX To -(game.boxY - self.Position.Y)
    Change attribute: self.offsetY To game.boxX - self.Position.X

    ...the movement in the rotation is achieved with the sin and cos functions used in the demo I linked before...

    As you can see, it seems like the x and y axis are swapped when used in the expressions...and every time I make an expression (i.e. a move one), it seems to get crazy with x and y coordinates... What I was trying to understand is if I have to make a group of rules for every rotation step (0, 90, 180, 270) or if I'm missing something...

    Thanks :)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited March 2012
    @rebzone

    I just watched a video of Rolling Kongs. It looks like a very, very fun game. And a game similar to this is definitely doable in GameSalad.

    You might be closer than you think! Go to a copy of the original demo that you downloaded. Then drag a bunch of the blue actors into the scene. Then use the blue actors to make the walls of a box. (Or any other shape.) The blue actors can be resized any way you like.

    Then shrink the yellow actor down to just a little box in the center. (It is just there to act as a controller. All the other blue boxes use its position and rotation as a reference point.)

    Play the 'game' and do a mouse down in the yellow box. All the blue boxes will rotate around the little yellow box.

    Now all you need to do is modify the yellow box's behaviors (like position and rotation) to suite your needs.

    RThurman
  • rebzonerebzone Member Posts: 25
    @RThurman

    Hi,
    sorry for the late answer, but I've been out for a couple of days.
    I just came back...I'll try what you suggest tomorrow evening.
    Thanks :)

    P.S. how can I upload my project (or a video/screenshot) to show you the behaviors I was talking about?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited March 2012
    @rebzone

    I modified the demo a little to show at least one way to have many actors rotating around a central point:
    http://www.mediafire.com/download.php?5z2wzcyyake4gz2

    The colors are nasty and there wasn't time to build a swipe mechanic. But the squares move into position like you want.

    Hope this helps!
    RThurman
  • rebzonerebzone Member Posts: 25
    @RThurman

    Hey, I've just taken a look at your demo...great one!!!!
    Anyway I think I'm missing something...I've done something similar, but with more complex rules...I'm going to re-create your demo from scratch in order to understand every single behavior...

    ...and thanks for your patience, of course :)
  • rebzonerebzone Member Posts: 25
    @RThurman

    Hi again, looking at your demo I think I understood what the problem was in my game: the rotate to angle behavior...
    I've tried to substitute it with interpolate, as you did, and everything seems to work correctly...don't ask me why :)
    ...so, if anyone else is interested in this template, I think RThurman demo is a great one....you just have to adjust offsets of the square actor depending on the rotation angle as I wrote some posts up here...in this way everything seems to work.
    Thanks again :)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    @rebzone

    Glad its working! It looks like you will have lots of fun with this project.

    RThurman
Sign In or Register to comment.