Rotate the Actor, Not his Orientation

RacetotheMoonRacetotheMoon Member Posts: 323
edited November -1 in Working with GS (Mac)
I'm wondering if there is anyway possible to visually rotate an actor, but to always keep his orientation the same?

When I give my actor the command to jump I want to see him rotate in the air 90, 180, or 270 degrees, which I've been able to do thus far. However, if he hits the ground with one of those rotations, and then tries to jump again, he'll attempt to do so at the angle that's relative to the position he started the scene, and not his new orientation.

So now, when my actor jumps and falls on his side (90 degrees) he now think the standard x 0 position, or right, is the direction he should be jumping. This certainly makes sense, but if possible I'd like to find a way around it. =)

So far I've tried all three rotate behaviors (Rotate, Rotate to Angle, Rotate to Position). Rotate is obviously the easiest to use, but has least amount of features.. the other two I've been able to use to a varying degree.. in fact, I thought perhaps the 'relative to' actor/scene switch would have been my cure all.. but no such luck.

Any help would be very much appreciated.

Comments

  • rebumprebump Member Posts: 1,058
    Handle the in-air rotation graphically through an animation behavior (i.e. set of sprites) instead of actually rotating him?

    If you use rotation, you need to bring it back down to original rotation/orientation to have a repeat jump in the correct direction or you will get the results you see.

    You could have an invisible actor that handles the jumping appropriately, always coming back down with the proper rotation/orientation and then constrain a visible actor's X/Y position to the invisible's X/Y position and then you would be free to rotate the visible actor as you see fit.

    I cannot really think of why you are trying to do what you are doing unless your actor is some funky ball/blob/star or something. What is the actor in question?
  • RacetotheMoonRacetotheMoon Member Posts: 323
    The animation suggestion is good, but would result in a canned response where I would want it to be more physics based instead. The second suggestion however sounds like it should return the results I'm looking for. Thanks!

    The object in question is just a box right now, but I was thinking it'd be a ball, or something else, I'm just going through the paces right now and trying to figure this engine out. It's fun to mess around with. :)
  • RacetotheMoonRacetotheMoon Member Posts: 323
    I coded up the second suggestion and it works quite well. Thanks again!

    Couple small notes:

    Since I have both actors visible until I lock the control down I've been able to see, much like my color blending code from the night before, there is some inaccuracy in the numbers Game Salad processes. While moving the visible character lags by a noticeable (eight pixels, or so) gap. It's not going to matter so much for the end result here, but this would obviously be a concern of mine if I were the develop team working on the engine, moving forward.

    I'm also running into an issue where sometimes (about 1 in 6) the visible square doesn't return to a position that's flat on the ground. It's turned ever so slightly. I think I might know how to fix this tho.
  • rebumprebump Member Posts: 1,058
    Yeah, the "real" values (sort of a by-product of the physics engine) used in an "integer" based 2D world lead to a bunch of rounding errors and/or fractional values that lead to slightly askew placements/rotations. It is best to mess with floor()/ceil() for cleaning up the placement whether it be initially, upon landing, etc. Of course, for certain games it doesn't matter such as floating around in the sky, space, top-view scroller, etc.
  • RacetotheMoonRacetotheMoon Member Posts: 323
    I still have to learn how to properly use those in the expression field. I'm very new to the programming side of things. :)

    I tried to implement them once but some how broke things.. I was going to go back and try again once I had a little more knowledge.
  • rebumprebump Member Posts: 1,058
    Just be sure to use the expanded expression editor to enter them and not just type them into the smaller textbox version of the expression editor field. For some reason, direct typing into the smaller version doesn't work almost all the time.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    My band has a song called "spinning" so I am making a jumping style platformer with a main character (a cartoon me with a guitar!) that jumps and spins. So I had the same issue. I am very pleased with the final result.

    Steps:

    1) Create 3 game attributes-

    game.playerX (integer or real)
    game.playerY (integer or real)
    game.jumpingUp (boolean)

    2) Create a square actor with a fixed rotation that will eventually be invisible. Put your jumping and right / left rules in this. This will give you a more consistent jump due to the fixed rotation. Constrain game.playerX to self.position.X and game.playerY to self.position.Y. Keep it visible during testing, then uncheck the visibility checkbox before release. Have a rule that says when self.linearmotion.Y is > 0 change attribute game.jumpingUp to true, otherwise false.

    3) Create an actor with the player's image.
    -Constrain self.position.X to game.playerX and self.position.Y to game.playerY

    RULE
    when game.jumpingUp is true
    Rotate (play with settings until it looks right to you)

    OTHERWISE (here's the key part)
    Rotate to angle 0

    So the image will rotate and at the peak of the jump will rotate to 0 degrees and will stop and fall without spinning until it jumps again in which it will spin again.

    I feel like I may be giving away the key gimmic in my current game, but the helll! Enjoy!

    Maybe those who use this will DL a ten speed taxi song from iTunes! ;-}
  • rebumprebump Member Posts: 1,058
    @scitunes: Sorry I gave away your secret method inadvertently! :-P
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I was only joking!
Sign In or Register to comment.