Am I over-complicating this?

0 favourites
  • 12 posts
  • I have some enemy zombies in the level, and each of them have 3 different ranges. The first is if the player is within a certain range, the zombie will start moving towards the layer. If they come within a second range, they start doing a ranged attack, and after the attack should continue moving towards the layer. When when the player is within a third range, the zombie should stop and start a melee attack.

    All throughout this, the player can shoot at the zombie, and the bullet collision sets the zombies animation to a hit animation, then should pick back up with either the melee, or the range/move, or the move animations.

    But with the animations being interrupted, I cannot rely on the On Fishished event, so I'm attempting to use that and a timer to reset some states.

    My event sheet is getting quite long and complicated for these different things, and I was hoping someone could take a look at the capx and tell if that's just the way it is, or if there's a different/better way of doing this?

    The CAPX

  • I can't see your cap because I don't have your plugins but if I understand what you are saying, you have:

    • 3 seperate animation events for 3 ranges
    • 3 bullet collision events (each one corresponding to the animations)

    If they are 1 or 2 frame quick animations which may or may not loop they should not get interrupted?

    I would not assign the bullet collisions to the animations. I have not had luck with that myself. I would create instance variable for the animations and say "when bullet collides with zombie - if instance variable ani2=true play die2" for example.

  • I'm using the Canvas plugin because I need to draw circles around each of the objects so I can visually see their ranges (it's a debug mode display)

    I have 6 different animations (for now) on the enemy object. Default (Idle), Move, Hit, Die, and GasAttack. I'll be adding a Melee attack animation soon enough. One of them, the GasAttack needs to play out until finished, but if a bullet collides with the enemy, then the GasAttack animation could get interrupted with a Hit animation. If so, then the GasAttack animation never finishes, and then never runs the actions on an On Finished event. After the GasAttack finishes, then the animation should either be set to Idle (if they're not moving) or Moving if they are moving. Plus there's a cooldown on the GasAttack animation.

    This is just one combination of things that could happen to an enemy. I'm trying to rebuild the events, but the different miscombobulations of events and actions or states an enemy could be in are what is complicating it.

  • This is where an instance variable could come in handy. I think like, creating instance variable "gas". if zombie animation plays "gasattack" toggle "gas to true". When animation "gasattack" is finished toggle gas to false. If bullet collides with zombie and gas=true, wait(length of gasattack animation) then play animation "die"

    ?

  • But that's not what I want. I want the animations to be interrupted, I jsut want some wqay of recovering from it gracefully. It doesn't make any sense to me for an enemy not to be "hit" if it's in the middle of an attack animation. It should interrupt, it should register as a hit, but it should be able to recover gracefully. An event of On Animation Interrupted would be helpful.

    The sad fact of the matter is if I was writing the code for this, I could write it very simply. But trying to do this type of thing in a visual event editor is making it more complicated than it really needs to be.

  • You should do it the same as you would write it I guess. "gasattack" toggle "gas to true". When animation "gasattack" is finished toggle gas to false. If bullet collides with zombie and gas=true, play animation "gasdie".

    If you understand about animations you will know that when there are frames missing the human eye will fill in the missing parts. It usually will not be apparent. You don't have to ensure that the next animation starts exactly where the last one left off for it to "look" smooth.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I can't really do it as I'd write it in code, seeing as I cannot do a switch statement, elses are problematic, and compound boolean expressions are close to impossible. Plus there flow of events, one doesn't have any real control over them and their order of executaion whereas in code I would. Oddly enough, I was able to do this very thing in GameMaker Studio, and it worked great but alas jumpthrough and moving platforms are a big PITA, which is why I thought I'd re-create it in C2. I really woulda thought it'd be easier or more accessible than this.

  • Can you give me a screen shot of your code?

    Instead of having so many ifs and elses, it helps just to make separate events.

    event1 - when gasattack finishes "do X"

    event2 - when bullet hits zombie and also gasattack animation is playing, "do x" then die (so that you don't lose the "do x" part on interruption.

    Maybe I'm not understanding the problem correctly. But I was trying to do a lot of ifs and elses like you and it did become problematic. When I made them separate events for each possible scenario, the correct one always plays.

  • It would take a considerable number of screen captures to get this all, seeing as it's more than just this. Too bad you don't have the Canvas plugin and could open the capx...

    I'm basically trying to build a state machine for the enemies, where each enemy could be in 1 of 6 states, each with it's own animation. Moving, Idle, Range Attacking, Melee Attacking, Hit, and Dying.

    Perhaps it'd be better if you tried it yourself.It works, I just feel that's messy. And I haven't implemented the Melee attack yet.

    Sample

    It hasn't been optimized for actual online, and I've never actually attempted to play it onlinse, so no guarantees it'll work well.

  • I guess I should've included basic instructions... Arrow keys are normla, LEFT & RIGHT... UP or SPACE is jump. 1 (not keypad 1) is shoot basic ammo, and 2 is a super ammo (greater range and more damage)...

  • I think it looks great

  • Experiment with it through several iterations and you start noticing the glitches in the zombie animations. Moving when he shouldn't, or the wrong animation, or not attacking when he should be, either skipping the Hit animation completely, or in a couple of instances, it just stopped on the hit animation and didn't do anything else. After trying it several times, it just doesn't feel right nor look right to me.

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