How to make actor jump and move like Geometry Dash?

AlkaPPAlkaPP Member, PRO Posts: 194

Hi guys,

Can someone show me how to make an actor like Geometry Dash? The actor rotate 360 degree each time it jump.

Thanks,

My Gamesalad Games On App Store:

Greedy Chubby: https://itunes.apple.com/us/app/greedy-chubby/id834371213?ls=1

Comments

  • SingleSparqSingleSparq Member Posts: 1,339
    edited June 2014

    Funny you should ask this. My daughter been playing it an I thought 'That should be easy to do!" not as easy as I thought but got it working somewhat.

    My test game is developing into something else but the main mechanic is this (note as I was writing this I changed a few things to make it work better - also this is a stationary way of doing this - meaning your main actor, the square doesn't really move forward, all platforms will be moving against it giving the illusion of moving forward);

    Add the following Global attributes:

    - JumpCount (integer)

    - Speed (real) Set to 300

    - BlockSpeedDivide (real) set to 80

    Create your main square and have it settings to:

    - Fixed Rotation ON

    - Moveable ON

    - Bounciness OFF

    Constrain the X position of the square to a spot you want it to be (224 for me).
    This keeps it from moving if hit by other collide objects.

    Add Accelerate to direction down on scene with 2,000 acceleration

    Set it to collide with other items (I tag the floor and other platforms and use that) - use a stationary floor actor (can be invisible) - 0 bounce, movable NO.

    Add these rules:

    Mouse down rule; (this cycles the jump so holding it down will keep jumping)

    If mouse button is down

    - Timer: every 0 seconds - Set change attribute game.JumpCount to 1

    - Timer: every 0.7 seconds - Set change attribute game.JumpCount to 0

    Jump Rule:
    If game.JumpCount=1
    ChangeAttribute self.motion.Linear Velocity Y to 700
    in Otherwise: (set particles here if you want some effect for speed when not jumping)

    Reset Jump Rule

    - If actor Collides with floor (or platform tag since you want it for any platform):
    self.Rotation to 0

    - game.JumpCount to 0
    otherwise:

    - Rotate to Angle - Angle: self.Rotation -90

    - speed 130 (stops on destination)

    (Note - I optimized these settings so that the rotation and jump work together enough so it lands on rotation - you can experiment if you want)

    This should give you the jumping effect you want.

    for other things moving towards the main block I place the following:

    Background and foreground movement:

    You'll have to figure out the best way for your parallax movement but my speed is 300 for foreground and divide off that for slower background stuff using the move Attribute on those items.

    Obstacles/platforms - these are set as Fixed rotation NON-Movable Objects because if movable they tend to get pushed when colliding with the main block - so I'm using interpolate to move them:

    Set to Collide with the block

    -Interoperate positionX to -100 (will get destroyed when outside the scene)

    Duration: game.Speed / game.BlockSpeedDivide ( I use the main scene speed 300 with the 80 of the BlockSpeedDivide - this seems to equal the 300 speed since you can't put it straight in there like the move function.

    Again this is all experimental and there are probably better ways (and more efficient) to do this but this was working fairly well for me - cheers!

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited June 2014

    For the rotation of the hero I would simply use Interpolate rotation to -360 over 0.6 seconds (depending how fast you want the spin using linear setting).

    You don't need to reset it back to 0 (do a display text to test the rotation of the actor to see why) basically when the actor reaches -360 its rotation is 0.

    See it in action below with a temp@$te I'm working on atm.

    Darren.

  • SingleSparqSingleSparq Member Posts: 1,339
    edited June 2014

    @DeepBlueApps said:
    For the rotation of the hero I would simply use Interpolate rotation to -360 over 0.6 seconds (depending how fast you want the spin using linear setting).

    You don't need to reset it back to 0 (do a display text to test the rotation of the actor to see why) basically when the actor reaches -360 its rotation is 0.

    See it in action below with a temp@$te I'm working on atm.

    Darren.

    Pretty good Darren, although both of ours are wrong on the flip. we should be using -180 as we want to flip from top to bottom instead of all the way around or 90 per side (just checked geometry wars on this)

    Edit: still need the self rotation rule on mine or it always goes 360 and setting duration to 0.3 works better in mine.

  • ArmellineArmelline Member, PRO Posts: 5,369

    Is it this kind of effect you mean? I've not played Geometry Dash.

  • AlkaPPAlkaPP Member, PRO Posts: 194

    Thanks @SingleSparq and Darren @DeepBlueApps. Yes @Armeline.

    I've figured out yesterday while waiting by constrain the self.rotation to -20 for 0.3 seconds and change it back to rotation 0. It is not a complete 360, but it looks fine. I will try Darren -360 for 0.6 seconds.

    Also, one more question, in both video from Darren and Armeline, the actor seems to be moving forward and jump 45 degree angle. How can it be since we constraint the actor to a certain position? When I constraint the actor, it jumps straightly up and down.

    Thanks again for all your helps,

    My Gamesalad Games On App Store:

    Greedy Chubby: https://itunes.apple.com/us/app/greedy-chubby/id834371213?ls=1

  • ArmellineArmelline Member, PRO Posts: 5,369
    edited June 2014

    @AlkaPP All I did was this:

    The timers are just because I had the actor fall and pause for a moment before starting to move, and can safely be ignored. It's not remotely necessary to have both timers either, I just separated them out to clarify the logic as I was working on it. The requirement to collide with the floor is just to stop you jumping again mid-air. Replace the -180 with -360 for a full revolution.

    I also included a "When actor overlaps/collides with Floor then Constrain Attribute self.Rotation to 0", just to be safe, but it isn't necessary. The slight gap between the actor and the floor in the gif above is something I couldn't find a way to prevent, and appears to be a bug in GameSalad. It happens unpredictably and even when I pared it down to the absolute basics it was still present. Definitely up for hearing about ways to avoid it.

  • AlkaPPAlkaPP Member, PRO Posts: 194

    Thanks @Armeline, i will give it a try

    My Gamesalad Games On App Store:

    Greedy Chubby: https://itunes.apple.com/us/app/greedy-chubby/id834371213?ls=1

Sign In or Register to comment.