Platforming Game Enemy AI [Castlevania Style Game]

Get help using Construct 2

Post » Thu Aug 09, 2012 7:38 pm

I'm working on a Castlevania style game.
Main problem I have is enemy AI.

Werewolf enemy - given bullet behaviour to enable left and right movement.

This works completely fine, he patrols back and forth just how I want.

I have input events that whenever the player gets within 96 pixels of the X of werewolf, the "group" that controls movements for the Werewolf is disabled. This in turn activates a second group/phase called the attack group.

During this phase, the Werewolf should instead of patrolling should be:

1) Be looking in direction/facing the player.
2) Move towards the player
3) Once he is within 32 pixels of the player, swipe at the character with a melee attack.

Step 3 I can manage no problem.
Step 1/2 I cannot figure out at all.
I've tried setting the Werewolf to "set angle towards position" (this being the X/Y of the player)
With this event he "rotates" towards the player, upside-down and whenever she jumps his angle changes, exactly what I don't want.

I've tried setting his angle to opposite of the player, but this would only work if the player never turns away from the Werewolf.

With this AI I need it contained within the Werewolf itself so I can spawn an unlimited amount of them, also they all act separate from each other and without requiring trigger blocks.

And sorry if this is hard to understand, my first post asking for help ever. I've no problem explaining other bits in more detail if required :)
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Thu Aug 09, 2012 9:14 pm

For Step 1, add an event that compares the X value of the werewolf and the player. If Werewolf.X > Player.X, that means that the werewolf is farther ahead than the player and should turn left. If Werewolf.X < Player.X, that means the werewolf should turn right.

For Step 2, just have him move forward once you set him to the right direction.

Lemme know if you need more explanation or an example or something, that wouldn't be a problem. And don't hesitate to ask for more help, we love helping out around here!
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Thu Aug 09, 2012 9:30 pm

Awesome! You are a life saver:)
It's worked a treat with the Werewolf, and I should be able to integrate this into the other enemy units.
Big thanks.
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Fri Aug 10, 2012 9:23 pm

Using the help from SullyTheStrange, the Werewolf now does everything I wanted in the OP. Only problem is when they is multiple versions of the Werewolf on screen, they all react to the events at once and not individually.
I'm utterly lost, and kinda rely a little too much on this problem being auto-fixed by the software itself. (MMF2 had no problem with this kind of thing, it seemed to handle each object individually)

Is there an easy way to integrate it into the current events framework I have?

Again I'll clarify anything and answer questions, and sorry if this makes no sense haha

B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Fri Aug 10, 2012 9:32 pm

There's a System expression "For Each" that almost always solves problems like these. Basically, take all those events dealing with werewolves, and make them subevents of a single "For Each Werewolf" event. If that doesn't work, I'll take a closer look at what could be going wrong there. But it should work.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Aug 10, 2012 9:33 pm

I'll give it a whirl, thanks again Sully :)

Discmach2012-08-10 21:50:44
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Fri Aug 10, 2012 9:41 pm

No prob! Hope the easy fix works.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Aug 10, 2012 9:50 pm



They all now attack at individual intervals, which is great, but when one detects me they still all detect me.
Which I guess to some degree could work in my favour in certain gameplay situations, .

The event condition "player object.X, 0, Werewolf.X, 0) < 96, would that be the problem. Anyway to change the script "Werewolf.X" to mean an individual Werewolf?

Its the only place I could see being the cause of the problem.
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Post » Fri Aug 10, 2012 11:44 pm

You could use the Werewolf object's "Compare X" rather than the System's "Compare two values". So you could rework that to say "Werewolf: X < player.X+96" and "Werewolf: X > player.X-96". That should give you the same effect while referring to individual werewolves instead of all of 'em.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Sun Aug 12, 2012 11:47 am

I tried it and it seemed to still affect all of them and not individually.
B
15
S
5
G
2
Posts: 154
Reputation: 3,076

Next

Return to How do I....?

Who is online

Users browsing this forum: Nifl, Yahoo [Bot] and 22 guests