monitz87's Forum Posts

  • Hi, I recently added a new feature to the game I'm making, and for some reason I'm taking a hit in performance.

    The debugger tells me the game averages between 150 and 200 objects, and collision checks/s go from 100 to 4000.

    CPU utilization ranges from 10 to 40%.

    The worst thing is that for some reason, the engine sometimes doesn't detect collisions between moving objects that were detected before (this is not consistent, I checked with save/load in the debugger, and most of the time detection works). I'm using the moveTo behavior and the fastest moving objects move at 200 pixels/s (their collision polygons are 10x10 in size)

    I won't post a capx for your sake (more than 250 events in the game), but if anyone wants to help and needs more information, I'll gladly provide it.

    Cheers

  • Add Opacity=100 to event 1.

    this

  • Both of the examples you posted as images should be fixed by using the "Else" condition between the "Selected = asdf" conditions. Though I agree with you on the first one, it shouldn't be necessary because triggers are supposed to run only once.

    I'm thinking that because of the nature of triggers, whenever you fulfill the condition of a trigger, it gathers all triggers of the same kind, queues them and checks if they are able to run because of previous conditions in order, so by the time they check the second one, the "Selected" condition is also true for that one, and it runs anyway.

    Else should be your solution

  • Have you tried with System->while?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should be able to do it with Else

    This should definitely work

  • Did you use System->Else on both of the events? (< X and > X)

  • Here's where I put it, is this still correct? The logic seems to make sense to me, but the enemy always plays all four animation frames before switching to enemystate "attack".

    [attachment=0:2um2sjtn][/attachment:2um2sjtn]

    Could you tell me where I could find in the manual (or elsewhere) how to write the expression for checking if any of a number of animations have finished? Basically I want to do something like:

    Enter the name of the animation that has finished: Animation: "enemykick1", "enemypunch1","enemypunch2" (that doesn't work of course)

    I seem to be able to find everything I don't need to know, but never what I do.

    I think I found the problem. You should put the overlapping condition before the other two, and use System -> Else.

    Most of the time, if two sprites are overlapping, their X coordinates aren't necessarily equal, so, for example, let's say that your enemy is already walking right towards the player when you enter the base level event, and enemy_bbox is overlapping player_bbox, but is still a little to the left (enemy_bbox X < player_bbox.X). You first enter the "enemywalkR" subevent, and it waits for 0.1 seconds (I'm guessing that's enough for some frames of the animation that was already playing to play out), it starts playing the animation again and only then enters the stop event.

  • As an action for enemy_bbox is overlapping player_box (and I don't know why there were two of those 'overlapping playerbbox' there, I removed one).

    Strange, it should work there

  • Where did you try using Stop Animation?

  • In fact, you could transform those last 3 events into only one, if you keep the names of the animations in an array and then do

    enemy_bbox isCurrentlyAttacking = 0 -> enemy Set animation to AnimationArray.At(int(random(3)) (play from beginning)

    ----------------------------------------------------- -> enemy_bbox set isCurrentlyAttacking = 1

  • :deleted last post, I think I got it working: Does this look right? Thank you very much!

    [attachment=0:zggap7g7][/attachment:zggap7g7]

    The last 3 events should be subevents of the first one, because if not you'll have them starting the animations even if they're not in the "attack" state. Aside from that, it should work perfectly

    Tell me how it goes

  • You can't do that in one event. Add the AND condition as a subevent.

    That's the sad truth. It would be nice if it could be done, sometimes this restriction leads to repeating events and actions unnecessarily

  • I just noticed that Sprite has triggers to check if animations are finished.

    Just have an instance variable on your enemy object "isCurrentlyAttacking" which you set to 1 when you start each animation, and have a subevent just below the 'enemystate = "attack"' condition to check for "enemy on any finished" with an action to set "isCurrentlyAttacking" to 0. You only start an animation if "isCurrentlyAttacking" is equal to 0

    (I didn't see the condition before because I was testing below another trigger, so it didn't show)

  • I'm sorry, but I don't understand how to write the code you recommended. For my example, would it be something like Add Condition -> Enemy Sprite -> Compare Frame -> Equal to -> "enemykick1" = enemy.5 -1 (I don't know how to write the last bit)?

    That's the condition. Replace Bullet with enemy of course. AnimationFrameCount is an expression that returns the amount of total frames in the current animation of the sprite.

  • If your attack animations don't loop you can have this check along with your enemyattack = x conditions

    enemy Animation Frame = enemy.AnimationFrameCount - 1

    This checks if the sprite is in the last frame of its current animation. However, this may cause the animation to be cut a little short (because the check could come as soon as the last frame starts), so I recommend you pad all of your attack animations by repeating the last frame at the end