Sheep AI that is very broken (novice programmer)

Get help using Construct 2

Post » Mon Sep 09, 2013 12:51 am

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:
http://iruka.iseenothing.com/Hunting_test_superbad1.capx

You get to play my hilariously broken game!
B
2
Posts: 2
Reputation: 154

Post » Mon Sep 09, 2013 12:32 pm

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: https://dl.dropboxusercontent.com/u/79803565/Hunting_test_superbad1.capx

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
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Mon Sep 09, 2013 12:43 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Sep 09, 2013 4:11 pm

A picture tells a thousand words. Nice @LittleStain
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Mon Sep 09, 2013 4:24 pm

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

Sometimes seeing is believing!
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Sep 10, 2013 2:53 am

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.
B
2
Posts: 2
Reputation: 154

Post » Tue Sep 10, 2013 6:31 am

@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.
B
13
S
4
Posts: 67
Reputation: 1,270


Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 20 guests