How to create enemies that change directions after bumping into a wall?

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.

    First off I'm new here, so I apologize if this is the wrong place to post.

    I have been working on a little platform game for the past 4 days and I have decided I want to add enemies.

    I want to add goombas and have them change directions after they bump into a wall.

    I don't want to use a method of using paths and I don't want to place invisible objects in walls that will change the goomba's direction.

    And this may sound silly but I'm looking for a method that is mainly based off events for the goomba.

    I followed Chris Burrows's Embedded Collision Detectors tutorial and it worked smoothly, but is there another method without Embedded Collision Detectors or attaching Collision Detectors to the goombas?

    Thanks :)

  • Try this:
    Enemy leaves the play area > Bounce

    Please login to see this link., Please login to see this link.
    Discord: Please login to see this link., Please login to see this link., Please login to see this link.

  • oh, probably because you're not using a movement that supports it, what movement are you using?

    Please login to see this link., Please login to see this link.
    Discord: Please login to see this link., Please login to see this link., Please login to see this link.

  • but then how would they reach the wall in the first place?

    Please login to see this link., Please login to see this link.
    Discord: Please login to see this link., Please login to see this link., Please login to see this link.

  • I mean when the player plays the game, how would the goomba move?

    Please login to see this link., Please login to see this link.
    Discord: Please login to see this link., Please login to see this link., Please login to see this link.

  • Does this tutorial help you any?
    Please login to see this link.


    Thanks for the comment.

    I followed that tutorial and managed to get a goomba working just like in the tutorial.

    But I was wondering if there was any other methods as this one just seems too "sketchy" and I feel like there is another method most people use when making such enemies.

  • The only alternative besides wall detectors is to have the enemy set an alterable flag.
    Flag 0 Off - Moving Left + Set Dir to <--
    Flag 0 On - Moving Right + Set Dir to -->

    So do something like this:
    - Enemy Flag 0 Off
    + Looking in Dir <--
    + Overlapping wall -> Set Flag On

    - Enemy Flag 0 On
    + Looking in Dir -->
    + Overlapping wall -> Set Flag Off

  • Thanks a ton for the help.

    I did what you recommended and added two lines of events to the goomba to make him not get stuck when landing.

    I made it so if the goomba is overlapping a backdrop (the wall/floor), then the game will subtract 1 from the goomba's Y-position.

    I made it so if the goomba isn't overlapping a backdrop, then the game will add 1 to the goomba's Y-position.

    This allowed the goomba to bounce of walls and walk across a floor even if the wall and floor are the same object.

    This worked perfectly, until I made a test level that wasn't just a flat floor.

    The goomba's will fall off backdrops (most of the time), but only if they are moving left.

    If the goomba's are moving to the right and they get to the ledge of a backdrop, then they will just switch directions instead of falling.

    It's hard to describe but I have the .mfa file Please login to see this link. for anyone who would like to check to see if they know a solution.

    There are very few events and everything is neat-and-tidy, so don't be scared to check it out.

  • Here you go I simplified your code and fixed your problem. You had to uncheck fine collision for the goombas in the properties window. I guess the foot animation was getting caught on the ledge edge and it made it switch directions. Turning off fine detection will treat the sprite hitbox like a rectangle.

  • Here you go I simplified your code and fixed your problem. You had to uncheck fine collision for the goombas in the properties window. I guess the foot animation was getting caught on the ledge edge and it made it switch directions. Turning off fine detection will treat the sprite hitbox like a rectangle.

    Thanks so much!

    I'm completely fine and happy with how the goombas work now that they move properly so again thanks for the help.

    Now one last thing.

    I don't want to get too greedy, as I got what I wanted but I was wondering what I would need to do to fix the goombas from moving 1 pixel up and instantly moving one pixel down after they collide with a wall on the left or right of them.

    I know why this happens, but I don't know how I'd fix it without destroying the floor collision.

    Again thanks for all the help :)

  • If the goombas turn around when they hit the wall, maybe the pictures for one of the directions is lower than the other.

    Sent from my SM-T280 using Tapatalk

    Please login to see this link., Please login to see this link.
    Discord: Please login to see this link., Please login to see this link., Please login to see this link.

Participate now!

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