Platforming Game Enemy AI [Castlevania Style Game]

0 favourites
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • 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 :)

  • 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! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • 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.

  • 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

    <img src="http://i365.photobucket.com/albums/oo96/5minapocolypse/gamecode.png" border="0" />

  • 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. <img src="smileys/smiley20.gif" border="0" align="middle" />

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

  • No prob! Hope the easy fix works. <img src="smileys/smiley36.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • I tried it and it seemed to still affect all of them and not individually.

  • I was wondering if by chance you figured this one out. I'm still trying to figure it out myself.

  • I didn't entirely fix it at the time, I was alot more inexperienced with C2 :)

    Looking at it now, I think the main problem was with containers.

    scirra.com/manual/150/containers

    Have a look through, see if you understand it.

    Sorry I can't be of any more help on it

  • guys why wont u put a capx file

  • I'd set up an instance variable to detect proximity of the specific werewolf to the player and as it is an instance variable only that foe would attack the character. Another solution would be to set up a Function which takes the werewolf id as parameter and alert only the foe of that id.

  • You don't have to use a bullet behavior at all! I tried making a game similar to this and here is how to do it... so give it a platformer behavior and put default controls to no. Now head to your event sheet and do the fallowing events...

    sprite.x < player.x

    ---- sprite: simulate platform pressing right.

    ---- sprite: set not mirrored

    sprite.x > player.x

    ---- sprite: simulate platform pressing left.

    ---- sprite: set mirrored

    Also if you want him to jump over stuff do this...

    is by wall on left

    ---- simulate control jump

    is by wall on right

    ---- simulate control jump

    I hope this helped!!!

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