Player Freezes randomly! A different BETTER way to do it ??

0 favourites
  • 13 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello All,

    I will do my best to explain what I did so maybe you can help me find a different solution for my issue.

    Just to be clear: (you can skip this part)

    Since I'm still a newbie who got lots more to learn in Construct 3, After working on my base-engine game focus on the Player mechanics I had so many issues and bugs that I've decided to Re-Code everything with much more organized way.

    So I made dedicated event sheet for the Player and one for the Enemies, I've created groups, comments and even an ON-SCREEN colorful Debug-Text that is really to-the-point for me to follow and test (I know that there is a wonderful debug-mode on C3, but it was hard for me to follow it) ANYWAY! everything is nice and easier compare to my first attempt of the code for my game and I learned new things on the way, good practice.

    So far so good, now... for THE ISSUES:

    I'm pretty sure that I code the all thing wrong and I need a different approach on how to do it:

    The instance (text) variable: "Movement" is set to "unlock" when the player is moving, jumping, etc..

    But when the Player Attacks it will set to "locked!" which will deactivated the INPUT-CONTROLS group and then activated.

    What it does basically is: when the Player attacks while in ANY movement, walking on floor / not on floor while jump, falling, he will stop moving even if you hold the right, left, jump, he stops on mid air or on the floor, do the attack and when the attack animation is done he can keep walking.

    This short example is just a RANDOM time when the player attacks and stuck, It's not happen just when he fall or jump, it could randomly happen just when he attacks on the floor as well:

    That "Movement" instance variable is obviously where the bug is, but I'm sure it's also the wrong way of do the all freeze-player after each attack while moving.

    That's the mechanics I want to make for my game, I know it will be easier to do without it... especially as a newbie but it FEELS exactly as I imagined it on my simple brain.

    The thing is... it's working!

    kind of, because I have a bug that sometimes randomly it will keep the Player on "locked!" which will freezes my Player. it's obviously related to that "MOVEMENT" instance variable I created and it's all over the place on my code, on any move as I explained so I can get rid of it and should find a different approach instead.

    I know it will be impossible help me fix the bug without sharing my capx, the reason I'm not sharing it is because my goal is to make it my official game, I hope that you understand.

    I'm not interested trying to FIX this bug because I already tried and my brain can't figure it out, I hope that you can still help me find a DIFFERENT WAY to code such thing.

    Maybe there is a more simple way? maybe even using some extra Plugin as a shortcut?

    Thanks ahead and sorry about my bad English.

  • I dont think you'll find a specific plugin for this.

    Im working on a game that disables the weapon depending on its level (like a shoot-cooldown). I did something like this, one of the diff being the control variable is global instead of an instance one.

    Your problem is probably at the point you change Movement to Locked. How do you unlock? How do you control it?

    In my case, i have a function called something like "disableWeapon" which changes the control variable, waits X seconds (X being the current cooldown of the weapon) and then changing the control variable back.

    What i mean is that i always enable the weapon after it being disabled.

    Maybe you have 2 events/actions/functions for this?

  • Thanks for the reply!

    Since I'm still a newbie, I didn't use Functions yet (I know I should, cleaner, re-use etc...)

    My movement is lock and unlocked based on a "on" and "off" (string) like Boolean but I like see it on the event sheet better. it's very much like what you described.

    For cooldown, which isn't the issue in my current major bug, first I did an old fashion cooldown with few lines and variable but then I realized... it's much simple to do with the Timer behavior and it works nice (for now, I didn't mess with it much to ran into issues, so maybe I'll change my mind).

    For now, once again... I'm re-code the all thing from scratch, I know it sounds stupid but it's a good practice for me to learn Construct 3.

    I hope that I will find a different / better approach to make the "freeze while attack" without getting my Player stuck randomly again.

  • Couldn't this just be a single event? When player attacks, disable platform behaviour, wait for 'timer', enable platform behaviour.

  • Try Construct 3

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

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

  • Couldn't this just be a single event? When player attacks, disable platform behaviour, wait for 'timer', enable platform behaviour.

    Yes it is, but since my code for the all thing was a complex overall I guess there are clashes so I re-make the all thing again trying to keep it even more organized as I learn.

    That made sense to me on my first attempt, but from what I remember the last time I used disable platform behaviour, my player fall from the floor (solid)... so I skipped that idea and used disable/enable groups.

    Maybe I don't use the disable platform behaviour correct?

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

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

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

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

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

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

  • 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!)

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