GameSalad

Round, Planet style gravity for actors?

JoeBJoeB Posts: 143Member, PRO

I wanna make an app where you can run on a round planet. How do I make it so that an actor can jump on and gravitate down towards a planet?

Comments

  • frdfrd Posts: 188Member, BASIC

    This is a method I've used, it's not perfect, but if you play with the numbers you should be able to get what you want.

    First find the x and y position of your planet. It should have fixed rotation, non moveable, 0 bounciness, and circular collision shape.

    Then in your hero actor (which should have 0 bounciness, non-fixed rotation, be moveable and have a rectangular collision shape)

    • Use an 'accelerate towards' behaviour with the x and y locations of the planet and check 'relative to scene', this will be like gravity (example speed 900)
    • Use 'move' in direction 200 for left and 'move' in direction 340 for right, check relative to actor, this will stop it from shooting off the planet, and add that the up key must be up (example speed 200)
    • Inside a timer of 'every 0.1' with 'run to completion' checked, use a 'rotate to' behaviour which also has the x and y positions of the planet, offset it by 90 degrees, check 'run to completion' and 'stops on destination', (example speed 1000) this will keep your actor correctly orientated.
    • For jump use a timer triggered by the up key 'for 0.5 seconds' and check 'run to completion' then use an 'accelerate' behaviour, direction 90 relative to actor (example speed 1500)

    Hope that helps.
    F

  • frdfrd Posts: 188Member, BASIC

    Forgot to mention that the hero actor has 'max speed' checked and set to 200 (or whatever move speed you use) to stop it from accelerating around the planet.

  • frdfrd Posts: 188Member, BASIC

    Had a shot at putting together an example. I made a few more tweaks to the jump.

    Demo file attached.

  • JoeBJoeB Posts: 143Member, PRO

    That's very clever! I will try this method, thank you!

  • UtopianGamesUtopianGames Posts: 5,670Member
    edited May 2016

    Here's one we made a while back if it helps.

    http://gshelper.com/shop/gamesalad-templates/soosiz-2/

Sign In or Register to comment.