User Tag List

Results 1 to 5 of 5

Thread: Need help with enemy combat system I'm making.

  1. #1
    Clicker Fusion 2.5

    Join Date
    Oct 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Need help with enemy combat system I'm making.

    Ok, so i'll try to explain this best as I can. So, in my game, you can go up to enemies and fight them, my game is a platformer. I have code set up for enemy movement, and I have set up detectors for when an enemy spots you. When an enemy spots you, a little alert animation plays when you get too close to the detector, the enemy then approaches and tries to hit you. That's all fine and good, but my problem is that when you leave the detection area, and collide with the detector again, the animation plays all over again. Why this is a problem is that it plays even when the enemy is walking towards you, the animation plays. I only want to have it play once, so when the enemy is walking towards you they don't play the animation mid-fight, as of course that would look strange and buggy. Is there anyway to get it to play once? Furthermore, is there anyway for them to play the animation once while they are also walking?

    Sorry, I know this is a lot to take in, but once you look at the mfa my rant will make sense; hopefully. I tried everything, but I don't think I have the experience to make it work. It was immediately obvious to try to use limit conditions and run the event once, but when I do that, the alert animation doesn't play again, so I'm trying to get the action to loop, but only once every time.
    Attached files Attached files

  2. #2
    Clicker Fusion 2.5

    Join Date
    Dec 2009
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really follow your code, although I admit I didn't look at it too hard, but I think line 113 where you stop walking and do the alert animation gets over-ridden by line 103 because your walking counter 2 is zero and triggers the start movement/animation.

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,307
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    You could try adding a flag. When the player triggers the enemy, see if the flag is Off. If it is Off then activate your alert and turn the flag On. This should prevent future alert activations. Just turn the flag Off if you need the behavior again.

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export Module
    butterfingers's Avatar
    Join Date
    Apr 2012
    Location
    London
    Posts
    135
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Ok, I took a look at your code and I can kinda see what's going wrong, but I think you have a couple broader problems that are going to make it pretty tricky to expand your game.

    First, you need to use the Alterable Values on the object to do things like set timers and so on.
    Second up, I think you'll be best off having a State Based system for your AI. Makes it much easier to break up your AI behaviours into Alerted, Moving etc etc.

    Anyway, I added a second frame to your MFA and wrote you a simple state based AI for the baddy, with a bunch of comments that hopefully explain what's going on in plain English.

    And yep, he now only gets alterted once

    help me I'm desperate.mfa

    Notes:
    It's simplistic at the moment, but I was trying to make it as clear as possible.
    I edited the ALterted animation so it worked in both directions
    Added a crappy red dot to the alerted animation so you can see it playing.
    Added additional direction to the attack so he can hit in both directions.
    Changed the player detection to maths/distance instead of colliders so it's more editable

    Let me know if anything's not clear

  5. #5
    Clicker Fusion 2.5

    Join Date
    Oct 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know this reply is late, but thank you so much butterfingers, you did a lot of the work in improving my code.

Similar Threads

  1. Finding nearest enemy + engage in combat fail
    By SevenSails in forum Fusion 2.5
    Replies: 0
    Last Post: 8th April 2017, 02:23 PM
  2. Replies: 1
    Last Post: 21st December 2014, 12:55 PM
  3. Counters & List combat system not working
    By Mindhack in forum Fusion 2.5
    Replies: 1
    Last Post: 4th December 2014, 05:16 PM
  4. Enemy Detection System
    By MikeB in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 27th April 2009, 11:09 PM
  5. Making unchanging enemy id's
    By LazyCoder in forum File Archive
    Replies: 4
    Last Post: 24th September 2006, 05:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •