Dashing and defending

Get help using Construct 2

Post » Tue Oct 03, 2017 8:56 pm

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! :)
B
3
Posts: 2
Reputation: 179

Post » Wed Oct 04, 2017 10:53 am

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:

Image Image

Code: Select all
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.


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

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 632
Reputation: 3,766

Post » Wed Oct 04, 2017 9:57 pm

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!
B
3
Posts: 2
Reputation: 179

Post » Thu Oct 05, 2017 11:01 am

Glad to help! Cheers!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
20
S
6
G
3
Posts: 632
Reputation: 3,766


Return to How do I....?

Who is online

Users browsing this forum: maranpis, totoe and 33 guests