Enemy Gravity with Acceleration

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hey everyone, I'm back again.

    I have an 'Active' object that is my enemy, and it has a Alterable Value 'ID' that is always spread to all the other duplicates of the object in the frame.

    I'm trying to make gravity physics using FastLoops and Alterable Values.

    I've tried setting 'ySpeed' Alterable Value where another Alterable Value named 'Gravity' is added to it whenever the 'Active' isn't colliding with a backdrop.

    Currently, the 'Gravity' value will always have 0.005 added to it as long as the enemy isn't on the ground.

    Of course, the 'Gravity' value resets to 0 when the enemy is on the ground.

    I have a FastLoop to check for when the enemy is in the ground. If so, it will subtract the 'ySpeed' value from the y-Position of the enemy.

    I have another Fastloop to check for when the enemy isn't on the ground, and it will add the 'Gravity' to the 'ySpeed' value I mentioned earlier.

    The enemy falls fine and accelerates as it falls, but the problem is that my enemy bounces like crazy when it's on the floor because it's trying to land but it's getting stuck.

    I'm not sure what to do and I've researched for hours.

    Again, help is appreciated :)

  • Let's say the enemy is 5 pixels above the ground, and falling at a rate of 10 pixels per frame.
    The next frame, it will be 5 pixels beneath the surface of the ground, so you set its Y speed to 0 and you subtract 10 from its Y position, and now it is 5 pixels above the ground - and because it's now above the ground, it starts to fall again.

    Instead of just pushing the enemy up by 10 pixels (or whatever if its Y speed was) when it hits the ground, you need to push it up one pixel at a time, until it is no longer touching the ground - and it needs to happen instantly, which means using a fastloop. There are plenty of examples of this if you search.

    btw: Using spread ID values and fastloops is an outdated way of doing things - use ForEach loops instead.

  • why You don;t use Physics object? You can make multiple physics behaviors in one object and change it on event

    Please login to see this link.
    please help - just give me a feedback

  • Let's say the enemy is 5 pixels above the ground, and falling at a rate of 10 pixels per frame.
    The next frame, it will be 5 pixels beneath the surface of the ground, so you set its Y speed to 0 and you subtract 10 from its Y position, and now it is 5 pixels above the ground - and because it's now above the ground, it starts to fall again.

    Instead of just pushing the enemy up by 10 pixels (or whatever if its Y speed was) when it hits the ground, you need to push it up one pixel at a time, until it is no longer touching the ground - and it needs to happen instantly, which means using a fastloop. There are plenty of examples of this if you search.

    btw: Using spread ID values and fastloops is an outdated way of doing things - use ForEach loops instead.

    I tried your suggestion but my enemy is still stuttering

  • You should only be moving your object 1 pixel at a time during the fastloop, therefore it can check for perfect collision and won't overshoot the ground or walls. So you move it by 1 pixel every fastloop, but if you want them to move at a rate of 10 pixels per frame, you would just run 10 fastloops.

    Also as MuddyMole has already suggested, you should be using foreach loops for multiple instances of enemies so it will loop through each one.


    Sent from my iPhone using Tapatalk

    Custom A* Pathfinding in MMF2: Please login to see this link.
    Random Tile World Generation: Please login to see this link.

  • You should only be moving your object 1 pixel at a time during the fastloop, therefore it can check for perfect collision and won't overshoot the ground or walls. So you move it by 1 pixel every fastloop, but if you want them to move at a rate of 10 pixels per frame, you would just run 10 fastloops.

    Also as MuddyMole has already suggested, you should be using foreach loops for multiple instances of enemies so it will loop through each one.


    Sent from my iPhone using Tapatalk

    What if I wanted to add acceleration to the enemy so the longer it falls, the more pixels it moves down? I'm currently trying this with decimals but am having no luck.

    And ah okay I'll switch to ForEach Loops once I get this figured out, thanks

  • Then you change the amount of loops to run depending on your acceleration number


    Sent from my iPhone using Tapatalk

    Custom A* Pathfinding in MMF2: Please login to see this link.
    Random Tile World Generation: Please login to see this link.

  • Then you change the amount of loops to run depending on your acceleration number


    Sent from my iPhone using Tapatalk

    Okay so that worked well when the 'gravity_' value was 0.2, worked perfectly actually.

    But when I changed the 'gravity_' value to something like 0.1 or 0.4, the enemy falls onto the floor and is about 1 or 2 pixels inside of it.

    I want it to work with any value I give to 'gravity_' just in-case I'd like to modify the gravity later on in the game

  • Add a fastloop condition that tests to see if the player is in the ground. If so, move it up by 1 pixel each time. So it will be pushed out of the ground. But since it runs in a fastloop it's instant and it looks like your player collides with the ground perfectly.

    Although if you're only moving the player 1 pixel at a time it shouldn't happen. You're testing to make sure the player isn't overlapping the ground when adding the gravity to the Y coordinate, right?


    Sent from my iPhone using Tapatalk

    Custom A* Pathfinding in MMF2: Please login to see this link.
    Random Tile World Generation: Please login to see this link.

  • Add a fastloop condition that tests to see if the player is in the ground. If so, move it up by 1 pixel each time. So it will be pushed out of the ground. But since it runs in a fastloop it's instant and it looks like your player collides with the ground perfectly.

    Although if you're only moving the player 1 pixel at a time it shouldn't happen. You're testing to make sure the player isn't overlapping the ground when adding the gravity to the Y coordinate, right?


    Sent from my iPhone using Tapatalk

    Okay so I added the FastLoop to move the enemy 1 pixel up when in the ground, and that's right.

    I am testing to make sure the enemy isn't overlapping the ground when adding the gravity to the Y coordinate

  • Please login to see this link.

    Reference this fastloop platform tutorial from Clickteam. It has all the basics you need.


    Sent from my iPhone using Tapatalk

    Custom A* Pathfinding in MMF2: Please login to see this link.
    Random Tile World Generation: Please login to see this link.

  • Please login to see this link.

    Reference this fastloop platform tutorial from Clickteam. It has all the basics you need.


    Sent from my iPhone using Tapatalk

    Okay so I took a look and tried implementing their method of handling FastLoops with gravity and acceleration, but I'm still getting that bouncing effect.

    I don't know, I'll take a second look at it when I get home

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!