Thank you for the toturial! Pretty proud how i was able to create what i have on mind using different toturials. An 8 directional movement of which accelerates until you meet the max speed.
@@1upIndie I actually fixed it! It had to do with the 0.707 returning such a weird number back, so I used round(spd*0.707), it isn’t quite perfect movement wise but it at least doesn’t mess up the animation!
Cooler Name. Not sure what's going on in your code to be honest, so cannot really help you on that one. One issue could be: I assume you may have "overlapping" sprites? Then your inputs are resetting the image being displayed constantly which results in a shaking of the image. Was that it?
@@1upIndie Vielen lieben Dank! It seems to have something to do with the number 0.707, but I'm not completly sure. The moment I set everything to 1 the diagonal movements don't stutter anymore but instead get blurry. So yes, it's probably an animation overlapping problem. At this point I am basically just trying to kinda replicate the basic movement system from GB Studio to GameMaker, which is harder than I initially thought. Whelp, I will eventually get to it.
Hm, that would need to be tied to a specific jump/gravity state machine. Fall damage is just a timer that is running down when you are in the state of "being in the air" (no collison below you is happening), so you run it down and when it hits a specific mark you damage the player (and of course you reset the timer when you land each time).
@Niel There is concept that is very popular for this kind of thing. It is called a state machine. Shaun spalding explains it pretty good here. Hope that helps. ua-cam.com/video/yfFzz9mZkU4/v-deo.html
Thanks for this video, I actually did this before but the way I did it was so bad cause I checked if the player was holding down 2 buttons to move diagonally ex. if (left) && (down) and obviously I had to do this for the other combinations which was clearly bad xD Although I don't know if its just me but the example game you have in the video looks natural with the diagonal movement reduction but obviously really sped up going diagonal but in my game with only 5 for my speed looks natural moving diagonal but like a sudden turtle like slowdown when moving diagonal with the speed compensation which looks really unnatural. I have a dash in my game though which for sure looks unnaturally sped up going diagonal versus straight so I only did the diagonal compensation when dashing and looks really nice 😁. Oh yeh I've seen some of your videos here and there and really enjoy your tutorial style. Seems chill and straight to the point with already having your code there to copy paste and explain it briefly. Subbed a few days ago, Keep up the great work 👍
Teorema de Pitágoras: a²+b²=c² En este caso lo ocupamos de la siguiente manera: √(a² + b²) = c Entonces para este caso en particular "a" es la velocidad horizontal (1 pixel) y "b" es la velocidad vertical (1 pixel), entonces si lo imaginás como un triángulo rectángulo "c" es la hipotenusa de ese triángulo rectángulo. Pero la mitad de la hipotenusa correspondería a la velocidad diagonal (0.7071067811865): √(1² + 1²) = 1.4142135623730 1.4142135623730 ÷ 2 = 0.7071067811865 No sé si Game Maker te permite calcularlo con alguna función incorporada, pero espero que se entienda. Este video es genial porque es muy sencillo, literalmente podrías hacerlo de esa manera, porque en este caso la diagonal siempre será de 45° por lo tanto la velocidad diagonal es siempre su coseno.
var SpeedNormal = 1.5; var SpeedDiagonal = SpeedNormal * SpeedNormal ; // get input for the keyboard var left = keyboard_check(vk_left); var right = keyboard_check(vk_right); var up = keyboard_check(vk_up); var down = keyboard_check(vk_down); // seperate into horizontal and vertical movement var hor = (right - left); // -1 0 1 var vertical = (down - up); // -1 0 1
// endresult to add to current x,y position var hsp = 0; var vsp = 0; // diagonal if (hor != 0 and vertical != 0 ){ hsp = hor * SpeedDiagonal; vsp = vertical * SpeedDiagonal;
} // no input or only pressed left/right or up down? -> then move normally else {
hsp = hor * SpeedNormal; vsp = vertical * SpeedNormal;
@@bobelpatron4280 This value (0.707) is set a multiplication value to normalize/even out the double speed that you get if you use for horizontal and vertical the same speed value (which is shown in the video). If you really really want to know why, well you can research Pythagorean Theorem and will get a rougly a multiplication value of 0.7 also. 0.707 is a bit more accurate, but not really world breaking if you "only" use 0.7. Hope that helps
@@bobelpatron4280 sin45° (and cos45°) is about 0.707, if you use the pythagorean theorem it will get too complicated in case you want to move at a different angle. For that you can just do sin(angle) for y speed and cos(angle) for x speed
I only needed the number 0.707 but this video was very helpful :)
:D, well you got what you were looking for. That is all I need to hear.
Thank you for the toturial!
Pretty proud how i was able to create what i have on mind using different toturials.
An 8 directional movement of which accelerates until you meet the max speed.
Basicly a 2d top down shooter game in which counter strafing can be used as a mechanic.
Gun accuracy determined by player speed.
You are welcome. I am not sure what you are trying to tell me here.
@@1upIndie don't worry about it just keep making great tutorials like this!
Damn, you came back with a bang! Good to see you back in action.
Well, that is some small bang :D, but thanks mate.
Never really understood why diagonal was faster, but yea, this clears it up
force+force=bigger force
@@foxbastergames1383 a^2 + b^2 = c^2
This is going to help a lot of people. Great job
Yeah, let's hope it does help out the community!
@@1upIndie i needed that in a previous project I started years ago. I lost thr file when my previous laptop crashed. I make backups now
This works perfectly, the only issue I’m facing is that the animation is blurry now when going diagonally because the speed isn’t a whole number :(
Hm, not sure what the issue is there to be honest...
@@1upIndie I actually fixed it! It had to do with the 0.707 returning such a weird number back, so I used round(spd*0.707), it isn’t quite perfect movement wise but it at least doesn’t mess up the animation!
Thanks man
The most helpful part of this were those last two lines. I was trying to use motion_add and motion_set XD
Yep!
I don't know why but my player characters starts to continuously stutter or shake every time I hold any diagonal button.
Cooler Name. Not sure what's going on in your code to be honest, so cannot really help you on that one.
One issue could be:
I assume you may have "overlapping" sprites? Then your inputs are resetting the image being displayed constantly which results in a shaking of the image. Was that it?
@@1upIndie Vielen lieben Dank! It seems to have something to do with the number 0.707, but I'm not completly sure. The moment I set everything to 1 the diagonal movements don't stutter anymore but instead get blurry. So yes, it's probably an animation overlapping problem.
At this point I am basically just trying to kinda replicate the basic movement system from GB Studio to GameMaker, which is harder than I initially thought.
Whelp, I will eventually get to it.
@@TarnkappenToast Hm, das wird schon!
Thank you!!! but how would I add a separate sprite when a diagonal is occurring.
Image angle might help with that. Maybe you could try putting
image_angle = direction;
inside of the step events
When I use this my character is super shaky when going diagonally
Hm, no idea how to help you out here.
Thank you
Youre are more the welcome!
Thank you for consistent uploads! Do you think you could make a tutorial covering fall damage in a 2D platformer?
Hm, that would need to be tied to a specific jump/gravity state machine. Fall damage is just a timer that is running down when you are in the state of "being in the air" (no collison below you is happening), so you run it down and when it hits a specific mark you damage the player (and of course you reset the timer when you land each time).
@Niel There is concept that is very popular for this kind of thing. It is called a state machine. Shaun spalding explains it pretty good here. Hope that helps.
ua-cam.com/video/yfFzz9mZkU4/v-deo.html
Thanks for this video, I actually did this before but the way I did it was so bad cause I checked if the player was holding down 2 buttons to move diagonally ex. if (left) && (down) and obviously I had to do this for the other combinations which was clearly bad xD Although I don't know if its just me but the example game you have in the video looks natural with the diagonal movement reduction but obviously really sped up going diagonal but in my game with only 5 for my speed looks natural moving diagonal but like a sudden turtle like slowdown when moving diagonal with the speed compensation which looks really unnatural. I have a dash in my game though which for sure looks unnaturally sped up going diagonal versus straight so I only did the diagonal compensation when dashing and looks really nice 😁. Oh yeh I've seen some of your videos here and there and really enjoy your tutorial style. Seems chill and straight to the point with already having your code there to copy paste and explain it briefly. Subbed a few days ago, Keep up the great work 👍
Thanks a lot for subbing! Hope you get your times worth on my small channel.
for vsp and hsp (diagonals) must multiply all with SpeedNormal
Correct
nice! how about one using analogue/stick control instead of keys?
I have 3 videos (or other channels cover that too) on that, simply search for gamepad, where you can find what you are looking for.
this is not hate or anything, but I am the only who feels like the movement is actually slower with .707 as multiplier?
Hm, maybe it looks like that. Mathematically it should be more or less on par. Dunno to be honest.
@@1upIndie ok, might be just my eyea
0.707 being the cosine of 45 degrees, yeah?
Yup.
√2÷2 = cos(45)
Teorema de Pitágoras:
a²+b²=c²
En este caso lo ocupamos de la siguiente manera:
√(a² + b²) = c
Entonces para este caso en particular "a" es la velocidad horizontal (1 pixel) y "b" es la velocidad vertical (1 pixel), entonces si lo imaginás como un triángulo rectángulo "c" es la hipotenusa de ese triángulo rectángulo.
Pero la mitad de la hipotenusa correspondería a la velocidad diagonal (0.7071067811865):
√(1² + 1²) = 1.4142135623730
1.4142135623730 ÷ 2 = 0.7071067811865
No sé si Game Maker te permite calcularlo con alguna función incorporada, pero espero que se entienda.
Este video es genial porque es muy sencillo, literalmente podrías hacerlo de esa manera, porque en este caso la diagonal siempre será de 45° por lo tanto la velocidad diagonal es siempre su coseno.
@@aaronmaldonado6562muy buena explicacion, muchas gracias!
var SpeedNormal = 1.5;
var SpeedDiagonal = SpeedNormal * SpeedNormal ;
// get input for the keyboard
var left = keyboard_check(vk_left);
var right = keyboard_check(vk_right);
var up = keyboard_check(vk_up);
var down = keyboard_check(vk_down);
// seperate into horizontal and vertical movement
var hor = (right - left); // -1 0 1
var vertical = (down - up); // -1 0 1
// endresult to add to current x,y position
var hsp = 0;
var vsp = 0;
// diagonal
if (hor != 0 and vertical != 0 ){
hsp = hor * SpeedDiagonal;
vsp = vertical * SpeedDiagonal;
}
// no input or only pressed left/right or up down? -> then move normally
else {
hsp = hor * SpeedNormal;
vsp = vertical * SpeedNormal;
}
//apply! to move the player
x += hsp;
y += vsp;
Why we need to multiply the speed by 0.707?
@@bobelpatron4280 This value (0.707) is set a multiplication value to normalize/even out the double speed that you get if you use for horizontal and vertical the same speed value (which is shown in the video).
If you really really want to know why, well you can research Pythagorean Theorem and will get a rougly a multiplication value of 0.7 also. 0.707 is a bit more accurate, but not really world breaking if you "only" use 0.7.
Hope that helps
@@1upIndie Thank you
You are an awesome guy ♥️
@@bobelpatron4280 sin45° (and cos45°) is about 0.707, if you use the pythagorean theorem it will get too complicated in case you want to move at a different angle. For that you can just do sin(angle) for y speed and cos(angle) for x speed
za ap and down moovement
Ja, zat iz korrekt