How do I implement a side to side dash function?

Just started using Construct 2? Post your questions here

Post » Fri May 20, 2016 4:45 am

I've been trying to make a platformer, and I've made lots of progress on my own and with google, but I've run into a problem. I've been trying to implement a dash function where you press either Q or E and get pushed a bit to the left or right, respectively. I've implemented a stamina setup, where it checks your stamina, makes sure it's equal to or above one, and then performs the action. It does this with my double jump, and does this with the dash. This has allowed me to troubleshoot and see that it's not a problem with the conditions, since it does subtract the stamina. I read on another thread that it might be a problem with my Max Speed. It's very possible that this is my problem as well, since I have my acceleration and deceleration set very high, because I don't want any ice physics. Thus, my Max Speed is effectively my speed. If you have any questions, feel free to ask, or you can download my project using the link below to see for yourself. Thanks for your time, and have a good day.

If you'd like, you can download my "Game" here: https://drive.google.com/uc?export=down ... 0d1UEhZQ28

Note: This is, as you can probably tell, a project for testing ideas, mechanics, etc. My "Art" is just made in paint, to quickly serve a purpose and not to look good. Sorry about your eyes.
B
3
Posts: 4
Reputation: 177

Post » Fri May 20, 2016 10:00 am

Hi,

It depends what you want to achieve. I would say you need to make it visually / mechanically distinct. So, you know the "stamina" part works, but you haven't revealed what is NOT working. I assume you just haven't managed to change the "speed" of your sprite with the platform behaviour. What have you tried? (post a screenshot of your logic)

I would be tempted to disable player input as soon as the "Boost" happens (triggering a timer) and then speed the player up, remove gravity and deceleration, and then re-enable them afterwards when the timer expires.. Perhaps something like this:


You will need the "Timer" behaviour on your Player object for this, and a new instance variable of type text called "Boosting", with default value "0".

Player.Boosting = "0" # Can't be run unless Player.Boosting is set to "0"
Event - "Q" is pressed
Set Group Active - "Movement" - disabled. # Disable your player movement group.
Start Timer for 1 second with tag "boost" # The duration of the boost.
Set Maximum Speed = 3x your normal speed
Set Gravity = 0
Set Deceleration = 0
Set Player.Boosting = "Left"
Set Player.Animation = "Cool.Boost.Animation"

Event - "E" is pressed
Set Group Active - "Movement" - disabled. # Disable your player movement group.
Start Timer for 1 second with tag "boost" # The duration of the boost.
Set Maximum Speed = 3x your normal speed
Set Gravity = 0
Set Deceleration = 0
Set Player.Boosting = "Right"
Set Player.Animation = "Cool.Boost.Animation"


Player.Boosting =/= "0" # When Player.Boosting is not "0" it simulates movement left or right.
Every Tick
Player.Boosting = "Left"
Simulate Platform Movement "Left"

Player.Boosting = "Right"
Simulate Platform Movement "Right"

Player.On Timer "Boost"
Set Group Active - "Movement" - enabled. # Re-enable player's movement group.
Set Player.Boosting = "0"
Set Maximum Speed = Default # what it was before the boost!
Set Gravity = Default
Set Deceleration = Default
Set Player.Animation = "Default"

I can do a mockup if you need it. Let me know if this helps!
B
8
S
2
Posts: 59
Reputation: 686

Post » Fri May 20, 2016 6:53 pm

Thanks for the reply, the general idea is that it would function sort of how the one in this gif does.

http://vignette3.wikia.nocookie.net/mag ... 0714114524

Basically, it would just push you a little bit, and would not be something that you press and hold. What I did was this:
http://imgur.com/E9pL9Hy

The problem that's coming up is it doesn't move the player at all, but it does subtract stamina and start the delay. I tried temporarily changing my max speed, as mentioned in this thread: applying-vector-x-to-sprite-with-max-speed-of-35_t73660 , but it didn't fix it.

You can see a full shot of my events here: http://imgur.com/cIngLut
B
3
Posts: 4
Reputation: 177

Post » Fri May 20, 2016 7:05 pm

What about temporarily disabling the movement of the player object at the start of the dash, using another, much faster object to perform the dash, and then repositioning the player object to the new location of the dash object?
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 201
Reputation: 3,460

Post » Fri May 20, 2016 7:43 pm

if you mean this type of dashing? example file.

i just edited you capx file a bit...

i disabled the stamina usage to 0 for testing purposes... c2 has some spawning problems on this capx and the shadow effect is a bit out of place. hey hope its what you wanted.


and hope you like your new player face .... got borred wanted to do something more then a green block haha
B
70
S
20
G
67
Posts: 1,316
Reputation: 42,305

Post » Sat May 21, 2016 1:51 am

if you mean this type of dashing? example file.

i just edited you capx file a bit...

i disabled the stamina usage to 0 for testing purposes... c2 has some spawning problems on this capx and the shadow effect is a bit out of place. hey hope its what you wanted.


and hope you like your new player face .... got borred wanted to do something more then a green block haha


Thanks, my original problem is pretty much fixed now, but there are a few minor problems that have arisen. I was thinking to have this look like a sort of backstep, which means the player wouldn't be mirrored. This is because the purpose I had in mind for the dash was to assist with lining up slow attacks, and quickly dodging enemy attacks. Of course, I can always just change the character to not be mirrored, but I also like the afterimage effect quite a bit. So the problem is that when i disable the mirroring that happens on the dash, the effect is still mirrored. Also, removing the mirroring of it doesn't always look right, since the player may dash in the opposite direction that they're facing, and the afterimage will be flipped the wrong way.

Because of this, I've decided there are two possible solutions, but I don't know how to implement either of them. Either have the afterimage be mirrored whenever the player is mirrored, or have the dash be a little bit slower, so as to look like actual movement rather than a teleport. Thanks, and have a good day.
B
3
Posts: 4
Reputation: 177


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests