GameMaker: Studio

GameMaker: Studio

View Stats:
How to add momentum for this situation?
I'm using this code in step:
//Player Movement hspeed = 5 * (keyboard_check(ord('D')) - keyboard_check(ord('A'))) vspeed = 5 * (keyboard_check(ord('S')) - keyboard_check(ord('W'))) //Collision if !place_free(x+hspeed,y) { speed = -6 } if !place_free(x,y+vspeed) { speed = -6 } if !place_free(x+hspeed,y+vspeed) { speed = 0 }
I have tried what this video says,
https://www.youtube.com/watch?v=XzvDhpnRVtE

However the code is not doing anything, and the character stops as soon as I stop pressing the keys. Here is how I've tried to adapt it to my case:
// Momentum acc=2 hspeed+=acc*(keyboard_check(ord('D')) - keyboard_check(ord('A'))) vspeed+=acc*(keyboard_check(ord('S')) - keyboard_check(ord('W'))) speed*=0.8

Can someone tell me what I'm doing wrong here, please?



< >
Showing 1-1 of 1 comments
Detonatress Sep 2, 2016 @ 10:44am 
How can I get a more accurate diagonal movement while using the hspeed and vspeed? It currently tends to go out of its path, and with this code (which is doing the momentum thing I needed) it seems all the more obvious that there is a bias towards the x or y axis.

hspeed += 6* (keyboard_check(ord('D')) - keyboard_check(ord('A'))) vspeed += 6* (keyboard_check(ord('S')) - keyboard_check(ord('W'))) friction = 0.2 if speed > 6 { speed = 6 }
Last edited by Detonatress; Sep 2, 2016 @ 11:12am
< >
Showing 1-1 of 1 comments
Per page: 1530 50

Date Posted: Sep 2, 2016 @ 8:45am
Posts: 1