Movable platforms

jb15jb15 Member Posts: 602
edited November -1 in Working with GS (Mac)
I'm trying to make a platformer type game, with moving platforms. I've searched some tutorials online, but haven't found any that talk about moving platforms (they all make you uncheck "movable"). I've tried messing around with it myself, but haven't had much success. Does anyone have any idea how to do this?

Comments

  • micksolomicksolo Member Posts: 264
    you will need to uses timers and interpolate. And yes unchecking movable is the right way too, as you will use interpolate to move, not real physics.

    So for example, to move a platform left or right you could do something like this

    First create an instance MoveState attribute for the platform (Inside the actor, if you don't know how to do this double click the platform actor, then on the left hand side in the middle you will see a "+" and "-". click the "+" to make a new attribute just for this actor.
    Then choose integer.
    Name the Attribute MoveState

    Inside the actor make the following rules

    Timer - Every 1 Second
    Change Attribute - MoveState -> (MoveState+1)%2

    (this changes the the state back and forth between 0 and 1 every 1 second)

    Create Rule
    When MoveState = 0
    Interpolate - SelfPos.X -> SelfPos.X + 100
    Duration 1 second

    Create Rule
    When MoveState = 1
    Interpolate - SelfPos.X -> SelfPos.X - 100
    Duration 1 second

    That should get simple platforms moving left and right. However you should know that using too many timers can slow down your game.

    You can mess around with the numbers to change the speed or how far they move.
  • jb15jb15 Member Posts: 602
    Thanks for the long post--unfortunately, it's still acting wierd. When the player lands on the platform, both rotate and roll, and the player zooms downward (I'm using accelerate as gravity) and the platform zooms off the screen.
  • gurechangurechan Member, PRO Posts: 211
    You need to turn moveable off for the platform.
  • icanmakeicanmake Member Posts: 466
    hey jb15 i threw together a template for u. if u give me ur email i can send it to you.
  • micksolomicksolo Member Posts: 264
    for the platforms:

    turn movable off
    turn fixed rotation on (to stop it rotating).

    When the player is on the platform you'll need to constrain the movement of the player to the moving platform.

    Get the platforms to work right first, then see what happens.
  • jb15jb15 Member Posts: 602
    my email is survey magnate at g mail . c o m. (all one word, no spaces of course). Thank you so much!

    I tried turning off movable--no go. I'd love to see your template, icanmake.

    micksolo, how do I constrain the movement of the player to the moving platform? I'm not sure how I'd do that. Would I make attributes for the box, or the player?
  • micksolomicksolo Member Posts: 264
    Hey buddy, check out the tutorial here -

    You're going to need to learn about instancing and setting unique ID's for each platform. Unless of course you have each platform as it's own individual actor, but that system is annoying because if you make 1 change to a rule in the platform you have to make over and over again in each actor.

    Better to learn how to constrain first, then learn how to set each platform as its own unique ID.

    I'd suggest doing something like this:

    Create a global attribute integer : Platform ID
    Create an instance attribute in the platform actor called SelfID
    Create a global attribute boolean called "OnPlatform" (set to false by default)

    In the Player actor:
    When collide with actor Platform
    Change PlatformID to PlatformID +1
    Change OnPlatform to True (otherwise OnPlatform = false)

    In the Actor Platform
    When OnPlatform = True
    Constrain SelfID to PlatformID (this sets an individual ID for each instance of the platform)

    Create a rule
    When SelfID = Platform ID
    Constrain PlatformX to SelfPosX
    Constrain PlatformY to SelfPosY

    (this makes it so that whatever platform the player is on, the global attributes PlatformX and PlatformY will set to the current platform. If you don't do this basically whenever the player touches a platform the code won't know where to constrain the player too as there are more than instance of the same actor, and it will probably crash.

    Hope this helps, if you need any more help or have trouble implementing it feel free to send the project file my way. But you should try to implement this yourself first, its the best way to learn :)
  • jb15jb15 Member Posts: 602
    OK--I've just been working through it. Thank you very much. I'm not sure if it's working yet for me, but it'll take a while for me to know, so I just wanted to say thanks everybody for your help. If I do all the stuff you're suggesting, and it still won't work after a while, I'll just move to my other project. Anway, thanks.
  • jb15jb15 Member Posts: 602
    I just found the template in my email inbox. Thank you so much icanmake!

    Also, thank you micksolo--I'm using the stuff you said to have the player only stand on the platform when it's on top of the platform, and not hitting it on the side.
Sign In or Register to comment.