Enemy AI

Get help using Construct 2

Post » Wed Oct 24, 2012 8:16 pm

Hello, I hope you can help me. I wanted to do is that when the enemy is at a distance x comes to attack
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Wed Oct 24, 2012 9:52 pm

Use the distance() expression.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu Oct 25, 2012 10:10 am

How it works?
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Thu Oct 25, 2012 2:11 pm

you can do me a small example?
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Thu Oct 25, 2012 2:15 pm

distance(player;x,player.y,enemy.x,enemy.y)

It returns the distance between the player and the enemy.

IF distance(player;x,player.y,enemy.x,enemy.y) < [EnemyAttackDistance]
THEN... Enemy attacks :)
B
17
S
4
G
4
Posts: 137
Reputation: 3,767

Post » Thu Oct 25, 2012 5:44 pm

I'm new to this program, you could do it in capx?
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Thu Oct 25, 2012 8:06 pm

Under the systems options when creating an even there is an option to compare two values. Use the formula Ragtime mentioned to perform the actions you described.

In short:
Event>System>Compare two values> enter distance formula to make the IF X distance
then do whatever you want them to do to "attack" the player.Herald of Time2012-10-25 20:08:55
B
7
Posts: 36
Reputation: 949

Post » Thu Oct 25, 2012 8:41 pm

Dear friend....what the learned Herald of Time and other fine gentlemen ...mean to say is that you should add a new event in the Event sheet click System Compare two values...it will look something like this... when you find it....
He means this...?

We could make you a capX but then you wouldn't learn where the button was..and for your next game it is a fair to reasonable presumption, at this stage that you would ask a similar question again..

If you are new to Construct 2 as you mentioned...The Newly finished MANUAL is a really good idea to "start" your epic adventures into becoming a star performer...Do some serious reading..Grab a few bikkies and a cup of tea coffee or yak milk and grace your eyes and brain with as many of the exquisitely crafted pages of the manual as you can muster in a single setting..The more you put in the more you will get out..
Do as much as you can to get familiar with the BASICS of Programming...you have to experiment...we all get it wrong..but try to do much of your own research before posting lest you appear trollish.:)...and look for other posts first if you can...you answer may already be out there...

In response to this thread and others, I am currently working on a Plugin BASIC-COMPLEX A.I.Sub-Routine for Construct 2 that will work for any Plat-former and eventually for any game time...I am doing plat-formers first because there is a lot of complex stuff that isn't needed in other types of games for enemy AI...
Complex AI takes time..so be patient and you soon will have a free Template for any platformer Enemy AI.. a Fully customizable template that will include node based path selection, patrolling, Targeting & weapons firing, Melee functions,evasion, Idle states etc..but yeah if you really are serious about being a game dev..better get reading...you will need at the very minimum 3 weeks of solid reading and experience to get a decent game going...its not too much...There is no "make game" button...a solid game AI can be hundreds of lines of instructions that all have to work seamlessly together and for any environment..making a Universal AI is not easy unless you want the A.I.to only do simple tasks like..just sitting there and saying "make me an AI"   


The plugin or simple Capx Template currently in the making will be fully commented so you can understand the ins and out of the system, and why everything is the way it is...

Be patient and read up in the mean time..its good for the mind...
My Plugin wont be ready for a week or so depending on testing...

In the mean time I recommend checking out farsmile90's "Chaos Game Example"
It has loads of cool features in there....if you can spend the time figuring it out...well worth the look at how Farsmile90 went about a simple AI
Unfortunately The Event Sheet is not commented at all so..
You may find it harder to follow but it does use the native/standard Construct 2 Event Sheet Scripting language...so it isn't too hard to figure out...and you learn at the same time....Great stuff...Kudos to "farsmile90"



Looking forward to seeing your first game...best of luck..

love and other fluffles


mystazsea2012-10-26 06:41:25
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
29
S
11
G
8
Posts: 313
Reputation: 7,335

Post » Sat Oct 27, 2012 10:57 am

Of the distance as I understood, but as I get the enemy go towards my to attack me.
action that I have to do?

Thanks for answering
B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Post » Sat Oct 27, 2012 4:41 pm

B
11
S
4
G
1
Posts: 410
Reputation: 2,752

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go and 26 guests