How to get an enemy to face its direction of movement.

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.
  • Im making a top down zombie shooter, and i have it set up so when the zombies are close to the player they follow the player. While following the player i use the expression "ATan2(Y( "zombie" )-Y( "Player" ), X( "Player" )-X( "zombie" ))" this causes the zombies to face and follow the player. Im now trying to figure out how to set the zombies to face their direction of movement. (Im using "Ball" movement on them). How can i make it so that the zombies face the direction they are moving so that it appears that they are walking forward.

    (forgive me if i have accidentally posted this in the wrong place)

    Contrary to popular belief, you don’t gain experience and knowledge by education and hard work. You get it from wandering around the countryside killing wildlife.

  • I just tried that, zombies still "walk" sideways an backwards.

    Contrary to popular belief, you don’t gain experience and knowledge by education and hard work. You get it from wandering around the countryside killing wildlife.

  • im only setting th angle with ATan2 for the zombies that are following the player. (The zombies with alterable value A equaling 1).

    The zombies that are set with ATan2 function the way that i want them to.

    Contrary to popular belief, you don’t gain experience and knowledge by education and hard work. You get it from wandering around the countryside killing wildlife.

    Edited 2 times, last by Narfafian (July 19, 2012 at 11:13 PM).

  • Assuming he doesn't, is there another way to do it that doesn't involve automatic rotations?

    Actually since im using the ball movement i was able to get automatic rotations to work, but the anti aliasing is really bad, and the turning was a bit choppy. Is there a way to do it where the turning is less choppy. When i was using ATan2 it was fine.

    Contrary to popular belief, you don’t gain experience and knowledge by education and hard work. You get it from wandering around the countryside killing wildlife.

    Edited once, last by Narfafian (July 19, 2012 at 11:29 PM).

  • That worked a little better, what i did was set the angle of zombies with Alterable value A = 0 to dir("zombie")*11.25 and set the angle of zombies with Alterable value A = 1 to "ATan2(Y( "zombie" )-Y( "Player" ), X( "Player" )-X( "zombie" ))". This way the zombies that are turning a lot have smooth turning, and the zombies that are just moving forward and turning when they reach an edge have the choppier turning.

    Thanks guys!

    Contrary to popular belief, you don’t gain experience and knowledge by education and hard work. You get it from wandering around the countryside killing wildlife.

  • I'm not sure if Eliyahu knows this, but automatic rotations only work with the built-in movements.


    I've been using MMF2 for years; I know this. ;)

    Narfafian specified that he was using Bouncing Ball movement, and last I checked, that was a built-in movement.

    I'm still confused why you're using trig and setting angle if you're using Bouncing Ball. What exactly is your movement? Is there any custom aspect to it?

  • Its just the movement that im using for the zombies that are wondering around the map, i haven't added any custom aspect to it, and ive only been using MMF2 for a couple of months, and the trig thing is just what i used at the time, and after testing the trig, and the automatic rotations, the trig seemed to be less choppy and the anti aliasing was better so i went with the trig for when the zombie is following the player since the player is moving so the zombies will be turning more than when they are just wandering around. Is there a movement that i could have used instead of the ball movement that may have worked better? I hope that made sense :)

    Contrary to popular belief, you don’t gain experience and knowledge by education and hard work. You get it from wandering around the countryside killing wildlife.

  • I like the Vector movement, since it's basically a 360 degree movement, but I find collisions to be a pain with it.
    Also, it sounds like you're using trig to aim at the player then moving towards the player with 32 directions, which would be causing the angle to be wrong if it has to hit an obstacle.
    What you can do is have your angle "approach" the current direction, as turning would do. That's a little extra math, and if I can remember correctly, takes two events in MMF2.
    A custom system would work, too.

  • Thanks, ill check the vector movement out, what i have is working great for the moment, but if i used the "approach" method would it use less CPU, because ill go for it if it is, but otherwise i haven't had any sort of problem because of the 32 directions, the target is big enough that I've never had a zombie miss its target, and its constantly correcting its course anyway.

    Contrary to popular belief, you don’t gain experience and knowledge by education and hard work. You get it from wandering around the countryside killing wildlife.

Participate now!

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