Enemy AI

For questions about using Classic.

Post » Fri Dec 18, 2009 10:27 pm

I have been searching around so much but i can't seem to find anything about it. I want to know how to make an enemy. When it sees the player it will chase him and if it dosent see the player it will walk around.

Thanks
B
1
G
3
Posts: 3
Reputation: 831

Post » Fri Dec 18, 2009 11:11 pm

Because of the LOS and RTS behaviours it's very easy to simulate AI (RTS has pathfinding and object avoidance) (LOS = line of sight).
You can add behaviours to an object by looking at it's properties and clicking : add behaviour.

Example,
IF enemy has player in LOS
+ move to: (Y) player.x (X) player.y (RTS)

IF enemy DOESN'T have player in LOS (you can invert conditions by right clicking on them and then "invert")
+ move to: (Y) enemy.value('ystation') (X) enemy.value('xstation') (RTS)

Enemy value "xstation" and "ystation" determine they're starting position. you can set those automatically with the event :

Start of layout :
set enemy.value('xstation') to enemy.x
set enemy.value('ystation') to enemy.y

This is of course a very (EXTREMELY) simplified AI, you just have to get more creative I.E. having the enemy's also check distance between them and player, make them stop and look around after losing sight of player and things like that :D .

Also : this is my first post!

Edit : If your talking about platforming AI, completely disregard my post :lol: .
B
2
G
3
Posts: 25
Reputation: 900

Post » Sat Dec 19, 2009 12:44 am

[quote="Kiwiman":1z4g048i]I have been searching around so much but i can't seem to find anything about it. I want to know how to make an enemy. When it sees the player it will chase him and if it dosent see the player it will walk around.

Thanks[/quote:1z4g048i]

You could set up "states" for your enemy. If the player is close, set the enemy state (a private variable) to "active." If the player is far away, set it to "passive."

Then you can use those private variables to run blocks of code that will control your enemy. You just need to use that variable as a condition in your events.

Other than that, what methods have you tried? It's easier to help someone fix something that's broken than just tell them how to make it.

(By the way, I cover some simple enemy AI in my Platform School tutorials.)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Dec 19, 2009 4:34 pm

I am a newbie at construct but eager to learn. Im trying to create platform enemy and i have tried all different behaviors but i dont know wich one i should use :/. I have used Platform behavior and LOS but i dont know what to do.
B
1
G
3
Posts: 3
Reputation: 831

Post » Sat Dec 19, 2009 6:33 pm

You're not going to learn anything if you don't learn HOW to learn 8) .
It sounds as if you think you can make a game from only using behaviours.

Since you're a beginner, I strongly suggest you create a bunch of 1-level projects and fiddle around in construct, testing events and figuring out what does what when and where, Instead of just throwing up your hands and saying : "how do I do this?".
B
2
G
3
Posts: 25
Reputation: 900

Post » Sat Dec 19, 2009 6:37 pm

[quote="Kiwiman":32b0pgl3]I am a newbie ...
i dont know what to do.[/quote:32b0pgl3]

Do this:

http://sourceforge.net/apps/mediawiki/c ... r_tutorial

Then do this:

viewtopic.php?f=8&t=2154
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests