Alon's Forum Posts

  • See image.

    Use a cooldown timer and count down per tick (subtract the cooldown timer by `dt` -- delta time). Only when cooldown timer is <=0 can the player attack.

    In the image above I did not cap the cooldown_timer to 0, so it will keep on counting down. You should put something like, if cooldown_timer < 0, then cooldown_timer=0.

    Thank you for the image and explanation, I will try to follow and do this.

    For matter of my organization: Can I use an Instance Variable on the Player like rest of the variables?

    or I must use a local variable like you did? I'm not sure if it matters or not as I'm still learning.

    to be honest I don't understand everything yet but maybe after I'll try to build it following your image it will make more sense to me.

  • Hello All,

    As I keep progressing working on my very first game on C3... I'm experimenting things.

    on my actual game things are much more complex even for me to follow, so I re-create a minimalistic .capx with almost the same idea.

    In my actual game-project I uses functions and animation priority so it's not exactly the same, I still want to see if I can re-create the solution on my game-project.

    Cooldown:

    My first attention was to make a Timer for the Cooldown, with no variables or anything but when I tried to do so I got confused and I tried a different approach which is "almost" working but not really.

    I describe on the attached .capx how to create the BUG, but I'll explain it also in here in case you didn't download it yet. the Debug-Mode shows the issue as well.

    The Bug:

    If on the start of the level you'll press 'C' many times as fast as you can,

    it will spawn more than 1 splash attack, that's the bug.

    My goal is to limit attack to: only one per X time.

    (probably less than a second but I will be able to change it).

    Thanks ahead for any alternative stable solution.

    Download .capx file HERE !

  • Wait and Trigger Once are probably the most misused events in Construct.

    Trigger Once is executed once when other conditions in this event are all true. (or, if there are no other conditions, then it will be triggered once on the start of layout).

    If other conditions become false and then true again, then this event will be executed again.

    Many beginners think this event means "trigger only once in the game", which is wrong.

    Wait is a convenient way to add a delay, but I prefer only using it for unimportant stuff and short delays - like Wait 0.5s, spawn Particles. It shouldn't be used in situations where you control game mechanics.

    Imagine you have an event like this:

    On collision with PowerUp sprite -> Player Set speed to 500, Wait 5s, Set speed to 200

    What happens when you pick up one power-up, and then after 4 seconds pick up another one? You expect it to "recharge" your speed for additional 5 seconds, however after 1 second the first "wait" kicks in and resets the speed back to 200.

    VERY GOOD explanation! I have much more to learn and test these on my actual game, so far it's the best way for me to learn thanks to you and others who help. even if I will or will not solve my current or future bugs I appreciate it a lot! I hope that others newbies will use this information if needed as well.

    I did transform from WAIT to Timers as you can see on the image above your post.

    But from your explain I get the impression that my use for wait is perfect since it's only 0.3 second or 1.0 second to activate and deactivate, but then I read the Article and understand it's not ideal for Functions so I changed to Timers... I just like how in 1 line we can put wait X seconds, while Timers are a bit more work but nothing critical of course.

    The "trigger only once" may confuse me because I came from ClickTeam Fusion and not that I was super-user but I started with the basic logic such as the "Every Tick" = "Always" when I compare it to Fusion... now I'm getting used to Construct 3 and everything is MUCH MORE CLEAN and fun to learn as I work on this game.

    I hope that you guys can have a rough look on the images above, maybe the issue is on my INPUT group or in the Timers and you can point me what I did wrong right away.

    I know it's not as good as explore an actual capx, but to recreate one takes longer then capture for a quick look.

  • Or maybe I did a mess with the Timers??

    After all it's the first time I use Timers instead of Wait.

  • Thank you for the information Kyatric this is very helpful!

    I will read that article and hope that I'll understand the idea consider I'm not a programmer.

    [quote:34tlidzb]By the sound of it, you are perhaps looking in the wrong direction though.

    If your arrows still allow to change direction, are you sure it is not in your keyboard events that something is messing up the overall logic.

    That's the thing, because I had issues with overwrite "HIT" animation on everything else I created this "Animation Priority-System" and it solved that Knocked-Back issue I had on my other post.

    That's why I thought I ruined so many other things because of that... big chance it's true.

    So, it is probably related to the keyboard as you said but the keyboards and attack are all in the INPUT group,

    at first I even put the Directions (mirror) inside, but it didn't matter so I separate it for organize sake.

    I have a feeling you will be able to tell where is the bug just by looking at my mess for the player on the attached images.

    I'm not expecting you to understand the mess from the images, but I wanted to share because it's better than nothing, you'll probably notice a big issue right away.

    Thanks again!

    This is the INPUT group:

    This is most of the ANIMATION group

    This is the Priority-System I came up with and it helped me so far with my early issue:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The best solution is to reproduce your issue/systems in a new project and provide us with a copy for it.

    It is not possible to investigate your issue as it is.

    The use of "Trigger once" is confusing in your collisions events.

    They are already triggered events that only trigger once while true.

    Nevertheless, with the added use of "Trigger once", your actions will only be executed once, and the next time your event is executed, those actions are supposed to be ignored.

    And this was before you used timers, who knows what your project looks like now. You do, we don't.

    Provide a copy of it and it will be easier for us to investigate and answer accurately.

    Thanks Kyatric! I appreciate your reply and detailed explanation.

    If I won't be able to solve this I will try to Re-Create a capx so the community can have a look and help.

    For now, I found a temporary solution but it is not perfect...

    I made that the "HIT" animation a.k.a "Anim_Priority = 1000" will set the INPUT group deactivate.

    so as I brutally press attack while collide with the enemy it works but the minor is that I can still change the direction of my character the moment he touches the floor for a milli sec and than the IGNORE starts.

    I even put the Direction / Mirror event inside the INPUT group but that didn't solve the issue.

    It's not how I want it to act because when Knocked-Out will always works that the Direction will stay the last one before collision. Anyway it's not critical but as I'm perfectionist it's annoying only for me, the player probably won't even notice this...

    As I'm still learning C3 and you guys are AMAZING with your tips, I would like to understand something:

    Trigger Once:

    How do I know if the action will trigger once or not? that's why I used it and it's not working well without the Trigger one... so I'm very confused now.

    Wait v.s. Timers:

    Should I actually NEVER use the wait? and use Timers only for less bugs and issues? or it's just in very specific parts?

    To be honest, the "WAIT" looks much cleaner with 1 line compare to Timer that needs a bit more (not bothering me, I'm just looking at my code now).

    Thanks again for the help and for your patience with me!

  • It's hard to understand what's going on by your screenshots, but I believe the reason for your problems is "Wait" action.

    You are creating multiple Wait threads, that can clash and produce unpredictable results. You should never use Wait in events like these.

    I recommend adding Timer behavior to your character. Disable controls, start "Ignore" timer, use "On timer" event to re-enable controls.

    The huge advantage of Timer behavior over Wait is that you can control it - you can restart the timer for a longer time if needed, stop it, pause (by setting object time scale to 0), calculate elapsed and remaining time etc.

    I know it's a total mess and hard to find my bug without capx but I appreciate your help, thanks!

    So since I'm still a newbie, I may did something wrong (again) but I tried your suggestion and I translated all my "wait" into Timers instead.

    The timers works just like the wait so I know for first time I did set the Timers correct consider it's new to me.

    The result = Exactly the same issue.

    Here is an example of actual what happens:

    1 - GOOD: When attack on floor or air, character stops (ignored for 0.3 sec)

    2 - GOOD: When touching the Enemy without attack, Knock-Back and Ignored for 1.0 sec.

    3 - THE BUG: When COLLISION WITH ENEMY + ATTACK, the main IGNORE 1.0 sec is not working as I need it. (Animation "HIT" works as it should).

    I'm not sure where is the clash exactly, that is why I don't want to continue add stuff to the game before I solve this major bug.

    I have a strong feeling it's related somehow to the Animation Priority System, but I can't tell...

    I'm still trying disable / enable some to get the idea what break it while scratching my head.

    Any other ideas? tips what can I try to solve this and make the first IGNORE to work over the Attack-Ignore ?

    Thanks ahead for any suggestion or help!

  • Hey All,

    Continue from my latest threads with my journey and learning as I go...

    Now I got into a new issue that I'm scratching my head can't solve it.

    I'm using 2 Separate IGNORE systems on my Player Engine:

    1

    - When the player collide with enemy he will Knocked-Back + IGNORE for 1 second.

    I also made an "Animation-Priority-System" so I can overwrite any other animation like in this case I want it to cancel any animation and play the "HIT" animation while the knock-back is happening.

    2

    - When the player press 'C' = Attack animation starts + IGNORE Player for less than a second.

    I made it so it will stop the Player on any movement including Walk / Jump / Fall while attacking.

    The mechanic's goal is to limit he player so he won't be able to MOVE while attacking.

    Current Status:

    When testing each case of the 2 Ignore, separately they are working GREAT!

    The Problem:

    When the player Jump or Fall while Attack + Collide with the Enemy there is a mess with the 2 ignores and it seems like currently it won't use the "MAIN" ignore as I want (IGNORE #1 with Knock-Back for 1 second)

    The result is mix of both and more like (IGNORE #2 the attack stops) mess it.

    It's probably an animation issue, I did try to solve it with the Animation-Priority-System I made yesterday which saved my Knocked-Back animation, which supposed to be the highest one.

    The animation does work on the highest priority but the IGNORE is NOT... working and I can control the Player while he is on the "Knock-Back" animation which is NOT supposed to happen.

    Again, if I test each IGNORE situation separate they work fine.

    I tried to add stuff such as:

    if Attack Animation is playing or while it is playing and stuff like that, nothing solved the IGNORE issue, the animation plays correct, but not ignored as it should.

    I'm not sure exactly how to fix this and hope you can help me out, I know it's hard without exploring my actual capx which I can't share but I'll do my best to show and give information.

    It's not a super secret capx, I just keep it as it's about to be my official game project, I hope that you understand and willing to help, I appreciate it a lot.

    Thanks ahead and Sorry about my bad English.

  • I CAN'T BELIEVE MY SYSTEM ACTUALLY WORKED!

    update:

    Remember how I was thinking about a crazy "idea" of making an Animation Priority-System on my first post?

    So... I decided to give it a try, basically because I didn't know how to accomplish the other solution which probably would be easier but as a newbie this is what I could think of.

    I wanted to share the Event-Sheet so more people will be able to see the solution and it may help others in the future BUT! I can't fit the all thing in one image when capturing...

    I wish we had a BUILT-IN FEATURE for capturing full event sheets within Construct 3!

    is this feature already there and I'm not aware off? if YES please let me know.

    So far it works like charm!

    I'm glad I didn't have to use fake animations, speed changes and such.

    I got much more control on ANY animation WHENEVER I need, I'm impressed by this tiny system and I hope it won't disappoint me on more complex parts of the game development.

    Here is a visual example:

    I use some slow-motion for my tests, that's why it's slow in some parts.

    And now, for the more complex part:

    "STOP PLAYER when attack on any condition" such as: Attack while Jump, Attack while walk, while fall, etc..

    It's not like the IGNORE, but it should stop the player, I may try SPEED = 0 or something first.

    That's why you see the "Movement" variable / text on my GIF...

    OH MY! I had so many issues with it on my last attempt... now that I Re-Code everything from scratch it may be working, I'll give it a try.

    Any suggestions on this will be great!

    Thanks ahead.

  • Thank you so much for the detailed reply.

    First I would like to try fix it with your suggestion of the conditions the problem is I'm not sure how to do the:

    when hit happens > animation 1 [/code:1lz2jbwn]  for example. I could found compare animation frame I guess it's not the same.
    
    The other thing is:
    My event sheets are separated, one dedicated to the enemies (all enemies, each one in group with anything related to itself and the player) so I will be able to use Enemies family if needed. for now I have only 1 enemy to work with anyway.
    
    So, the collision between the Player and the Enemy is split to 2 events, that's where I scratch my head while my event sheet is very organized.
    
    As you can see on the images attached, the collision is based on the Enemies Event-Sheet.
    While the "IGNORE" works on the Player_1's Event-Sheet. 
    [h2]I disabled "flashing" for this test, it is related to the invincible time which works perfectly fine.
    Line 22 and above is the SAME for the other side of the knock-back no need to show it again.[/h2]
    
    On Player event I selected to show which are the 2 events that if I disable, EVERYTHING WORKS consider walk and idle won't act correct as explained on my original post.
    
    ENEMY EVENT SHEET specific part of the knock-back + ignore for 1 second:
    [img="https://i.imgur.com/TPwsNGe.jpg"]
    
    PLAYER EVENT SHEET - Animation priority issues to fix:
    [img="https://i.imgur.com/YBCOwq6.jpg"]
    
    I'm guessing that I need to mess with the code on the  "Ground animations"  part to solve the issue, 
    But I'm not sure how exactly... noob mode + confusion level = HIGH   
    
       Can you please help me out guide me how to do it or show screenshot? mini-capx?
    Any visual way will probably help me try your solution it make lots of sense to me and I rather try it before the "fake animation" playing with speed and what not.
    
    Thanks ahead!
  • Hey All!

    Continue to my latest thread where I Re-Program the ALL base engine of my game:

    I'm working on the Player's basic mechanics now and how he will react as a platformer while interact with other objects such as enemies.

    Since I can't share the capx, I'll do my best to describe and SHOW the issue and maybe you can help me out here:

    The short version:

    The Problem: Player's Animation Priority is acting weird with a delay.

    When the player collide by enemy: "HIT" Animation stuck on first frame for a bit then playing. My guess is because of the Platform animations priority: IDLE / WALK on floor / not on floor etc..

    The long version where I try to describe best:

    (Sorry about my bad English.)

    I have: INPUT and ANIMATION GROUPS so I can handle the Knock-Back (ignore INPUT on enemy collision).

    So far so good, everything works!

    Originally, the player also Flashing when collide with enemy, but for better visual example on the specific animated GIF I disabled it so you can see the issue.

    THE ISSUE:

    As you can see the on collision the player is "trying" to run the "HIT" animation from beginning but it stops for a few ms and then begins.

    I tried MANY ways to solve this:

    • I made the animation to start when the variable IGNORE is "on" and back to idle when it's "off".
    • I tried when Flashing is on run the "HIT" animation, and back to idle when it's finished.
    • I tried to make a dedicated Boolean variable for the "HIT" animation condition.
    • I tried to cancel other animations while HIT is on, got messed up results.
    • I tried to "force" the HIT animation using every tick.

    All these and other attempts failed... (probably because I don't understand Construct yet, still a newbie)

    In my simple brain it should be easy:

    as long as IGNORE variable is "on" the "HIT" animation is playing. when it's "off" change to IDLE animation.

    Right now on my current code, the IGNORE works on collision for 1 second (with or without Flashing) so it's not depending on the flashing time. there is a "wait 1 second" on the collision event which ignore my INPUT group and it works fine.

    Player "HIT" Animation is 2 frames (loop forever just like idle so I can use stop it when I want)

    My Conclusion:

    After some tests, when I disable these 2 events:

    • Platform is moving + Platform on the floor = Set animation to "WALK" (play from beginning)
    • Platform on stopped + Platform is on floor = Set animation to "IDLE" (play from beginning)

    ONLY THEN the "HIT" animation works correct as it should once the collision happen for 1 second (that's what I want) then back to IDLE.

    BUT... now there are no WALK and IDLE animations because these are the BASICS of my player animation movements.

    I do have other animation conditions such as JUMP, FALL, Landed.

    I disabled every single one to make sure that the problem is related to what I've mentioned above and it make sense that it can't play the "HIT" animation because it must play the other animations first, only THEN it will play the "HIT" that is why there is that DELAY that looks like it freezes the first frame of the "HIT" animation and then when the Player stops it will continue playing it.

    So what is the solution?

    How can I set the priority of the "HIT" animation to take-over all the others while IGNORE variable is "on" ?

    The only way I can think of right now is a bit more advanced for my level but my stuuupid brain tells me to try and build some kind of ANIMATION PRIORITY SYSTEM using a variable to control each animation on specific events to overwrite each other when needed.

    it's nice in theory and all, but please consider I'm still new to Construct and it's I'm learning as I build this game, I still have much more to learn but I hope you can guide me to a simple-as-possible solution.

    Maybe there is a plugin, or built-in feature to solve this?

    maybe my conclusion is wrong and it's not even the issue and the solution is totally different?

    Yes... I'm very confused.

    Thanks ahead for any help!

  • It's a common problem I see on here as the animation checks get way out of hand, branching off into something like if player is on floor, and is not landing, and is not shooting, is not moving, then play this animation, then it becomes impossible to follow. Better to start with basics for these animations and keep it as simple as possible.

    Exactly! so I got most of the animations to work great but I still have this issue now where the Player got HIT by the enemy, so because of all the other conditions (floor / air / negative etc..) it acts weird.

    Plus it works on the Knock Back so I activate the "HIT" animation when the player is on specific time... I hope I'll solve these issues, I didn't even got to the REAL-ISSUE of the attack yet.... (noob-mode!)

  • Yeah I can imagine where the problems are with the inefficient events. As you get better at Construct you can limit the number of things you are checking against. For this you would put conditions at the start of the player's general movement saying that they are not frozen, then if they are frozen you set idle animation. Unfortunately you are now left with a bug that you'll have to debug and find out the problem. The likely cause is the timer not resetting as expected.

    True, that's why I try to organize things in groups so I will have more control. but still it won't solve everything because there are lots of things goin on for all the animations + platform player.

    Unfortunately even without the Timer, and just Boolean the bug was there... that's why I'm trying to re-code it for now, but I get so many other bugs with the animations now.

  • Well maybe not disable the whole behaviour but you can restrict movement by setting max speed to 0.

    I tried that as well, but even that the platform can't move (zero speed) animations are still acting.

    That's why I chose the deactivate / activate groups... again, I'm just a newbie so I have lots of more to learn.

  • If you could post a couple prints on where you have this actions we could imagine whats going on.

    About not posting the capx and etc, worry not. I fully understand your concern.

    About the function, you should really check it. Its REALLY easy. It would be something like this:

    Function freezePlayer()

    .......................................set "locked" to Movement;

    .......................................wait 0.3 seconds;

    .......................................set "unlocked" to Movement;

    Then whenever the freeze has to occur, you call freezePlayer().

    About the Timer behaviour, i think it is overkill. Do you start it whenever the freeze occurs and have a "On timer complete" event to set "unlocked" to Movement ? My first guess would be timers overlaping somehow.

    Since I already start-fresh the all code, I will see where I get to this point once again and then I'll post some pieces of the event sheet.

    I have no problem sharing that, but the capx itself, I'm glad that you understand me.

    I'll keep on update on my upcoming issues... coming soon! (I guess)

    Thank you all for trying to help I appreciate it a lot!