Dashing and defending

0 favourites
  • 4 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hello everyone,

    I'm trying to make a combat/movement system similar to that of Hyper light drifter or Hob and having a hard time figuring stuff out. I'd be very grateful to receive help or tips on how to think about this, since i'm very new to this and also not very logically minded

    What i'm trying to figure out is the movement of it all.

    Apart from running around (which i use the 8direction for), i want the player to be able to:

    Dodge - a quick forward motion in the current direction

    Attack - stopping player movement while attack is active

    Defend - decreasing movement speed when holding LT

    Dodge - i've done this one by using a boolean and increasing player max speed for a certain amount of time with "wait" and then setting it back to my default value. and this seems to work alright. this is on button pressed

    Attack - the player should stop and take a swing when attacking, and i used the same method as the dash but decreasing max speed instead. this also seems to work.

    The problems start with the defending.

    this one should be active only when the player holds the left shoulder trigger.

    I use a boolean and decrease the max speed when the player holds LT and then sets it to 80 (which is my default speed) if not. This value seems to override all the other events though, since they no longer work.

    I can't wrap my head around this and any suggestion would be highly appreciated!

  • I haven't seem the capx, so it's hard to tell exactly what is the problem. But, it seems to me you are changing the speed directly according to the situation and I believe it would be a better practice, and less prone to errors, if you implemented it as a state machine, in whch the conditions would set the states and the states would affect the attributes (like speed).

    In a state machine only ONE state is active at any given time and each state has some conditions that tell the machine to change to other states, thus, overlapping conditions would not occur a states would alternate. What I think is happening in your implementation is that overlapping concurrent conditions are trying to change the attributes simultaneously.

    Here's an example of a very simple state machine that you certainly know:

    Current State	Input	Next State	Output
       Locked       coin    Unlocked    Unlocks the turnstile so that the customer can push through.
                    push     Locked     None
      Unlocked      coin    Unlocked    None
                    push     Locked     When the customer has pushed through, locks the turnstile.
    [/code:b6bspk3l]
    
    Source: Wikipedia.
    
    Sorry if I don't show any code, but it's hard to when I don't know your capx.
    
    Hope this help. Cheers.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for your explanation and example of a state machine, it was very helpful and sent my mind in the right direction.

    It all seems to be working correctly now.

    I did something like this:

    player_state = 0 setmaxspeed to 80

    player_state = 1 setmaxspeed to 300, wait 0.2, set player_state to 0

    and so on, and it seems to work as far as i can tell.

    cheers!

  • Glad to help! Cheers!

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