Sheep AI that is very broken (novice programmer)

0 favourites
  • 7 posts
From the Asset Store
Black Sheep spritesheet for side scrolling action adventure endless runner 2D mobile game.
  • So I'm a visual artist by trade, and learning programming is really, really foreign to me. "novice" implies that I am sorta learning, and in truth I am probably below that haha. Please be patient with my newness, I will try my best to understand!

    I am trying to make a pretty small game, but the very first snag I've hit is major.

    In my game, I need "sheep" and other prey to do a few things

    -Have randomized movement

    -Flock together, occasionally, on grass. Slow down when in the grass.

    -Run away if they see the player, to a safe distance

    -If the player is sneaking, ignore the player for a certain distance, when the player is close enough, run away.

    From searching, I tried the 'boids' plug in, but found the mechanics unsuited for the other traits I needed to add. I am unsure if the mechanics I am trying to achieve are too complex for my skill level, but I figure some of you could help me see the flaws in my logic.

    here is the file:

    You get to play my hilariously broken game!

  • Another way to tackle randomisation, is to use the sprite with a forward motion and every now and then modify it's angle, speed etc. This will give a greater variety of movement and make the sheep far more natural looking. I would consider abandoning the 8 direction for the sheep. There are a lot of permutations you can do. Instead of using the bullet you can event the forward movement. Combined with instance variables you can set sheep speed in the events also.

    Have a look here:

    I have not analyzed your sheep movement 100%, but I also think that your events are conflicting with each other, giving the sheep that epileptic fitting every now and then. A good idea is to work with a single idea, ie change direction every now and then. Get it working perfect. Then implement the next thing. It helps to see when one thing breaks the other.

    Good luck

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It would seem the boids plugin would achieve exactly what you are trying to do, so I'm interested in why it doesn't suit your needs. Sprites aren't limited to one behaviour and switching between them can help to achieve some great (and sometimes unexpected) results.

    For randomized movement you could also try adjusting my Fly-example.

  • A picture tells a thousand words. Nice LittleStain

  • AngelEyes, I was a bit surprised, but your description sounded exactly like that fly-example I made some time ago.

    Sometimes seeing is believing!

  • Thanks for the responses!

    AngelEyes your example is alot less complicated! I had to look up what the *dt was, so that's a new thing for me to read about, thanks! I will try and be more logical about my workflow.

    LittleStain So, when I was playing with boids it seemed to shoot my sheep off onto endless loops getting really super fast without a way to slow them down. I also want the sheep to move relatively independently but just sort of tend towards flocking, which I figured I can replicate with the grass. It was probably user error, of course, I will keep playing with it.

  • LittleStain, have been using it for a game that I am making, not quite as frenetic, but the same idea. Never heard of Boids Plugin.

    Iruka, only worked on dt recently, really important to implement into all your games. If you missed it in the tutorial behaviors do not need it as it is already incorporated.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)