Does move_and_collide() handle diagonal movement properly (use a unit vector)? If not, what is the proper way to do the heart movement so that it will not be faster when moving diagonally? This is important and many tutorials on other channels do not handle it :(
Move_and_collide does automate a lot of things (push back for example). Diagonal movement is not an issue now. If you have diagonal movement simply redude the speed to 0.7 instead of 1. In this video you can add write it like this: var move_x = right - left; var move_y = down - up; // this is the additional part, if diagonal movement/input is there, reduce the speed of both so that it correct again, else it goes faster if applied if(move_x != 0 and move_y !=0){ move_x = (right - left) * 0.7; move_y = (down - up) * 0.7; } move_and_collide(move_x, move_y, obj_Action_Box); Hope that helps!
@@oldshiloh9061Not sure I get what you try to tell me here. For example the result value of right - left can be -1, 0 or 1 (same goes for the other). That you can multiply by the actual speed value you want to set for your game (1, 5, 50). That if it is diagonal you can multiply again by 0.7 (it is 0,7071067811865 if you want to be ultra precise, cosinus of 45 degrees). var speedSet = 5; // the length/speed value how fast to move forward/any direction var move_x = (right - left) * speedSet; var move_y = (down - up) * speedSet;
if(move_x != 0 and move_y !=0){ move_x = (right - left) * speedSet * 0.7; move_y = (down - up) * speedSet * 0.7; } Was that what you were looking for?
@@1upIndie I am telling you that the correct way to do it is to use a unit vector. It is more accurate and works for all angles. If you think that redoing a square root (only when the direction changes) is going to slow down your game, you are wrong. Your 0.7 is assuming that it is always using the square root of 2, and this is wrong. You are avoiding the correct solution for no reason at all.
@@oldshiloh9061Hm, then then answer is: No. Move and collide does not use vectors and it is a simplified way to create 2D movement. I do understand that vectors are faster and the standard for Unity/Godot/Unreal but not in GameMaker. Can you do vector movement? Yes, but you have to do by hand then and there are no functions (at least in my knowledge, correct me if I am wrong) in GameMaker to automate that. Godot does have move and collide also but is used different, with velocity * delta for 2D space. Check out DragoniteSpam, he does use GameMaker with 3D functionalities in mind and maybe has the answer you are looking for or ask the pros in the GameMaker discord directly. This video does cover the topic: ua-cam.com/video/7ny19lk52RU/v-deo.html
Well, I have to go with small chunks, else this could be done in around 5 sessions. Nobody (at least for my videos and not tutorials in general) watches videos longer then 10min.
Code from the player Heat object's step event: // get input from the keyboard and store in variables var right = keyboard_check(vk_right) or keyboard_check( ord("D")); var left = keyboard_check(vk_left ) or keyboard_check( ord("A")); var up = keyboard_check(vk_up ) or keyboard_check( ord("W")); var down = keyboard_check(vk_down ) or keyboard_check( ord("S")); // get horizontal/vertical movement and store in variables, use a multiplier (2) to speed up var move_x = (right - left) * 2; var move_y = (down - up) * 2; // use the move_and_collide function to auto move the player heart instance move_and_collide(move_x, move_y, obj_Action_Box);
Does move_and_collide() handle diagonal movement properly (use a unit vector)? If not, what is the proper way to do the heart movement so that it will not be faster when moving diagonally? This is important and many tutorials on other channels do not handle it :(
Move_and_collide does automate a lot of things (push back for example). Diagonal movement is not an issue now. If you have diagonal movement simply redude the speed to 0.7 instead of 1.
In this video you can add write it like this:
var move_x = right - left;
var move_y = down - up;
// this is the additional part, if diagonal movement/input is there, reduce the speed of both so that it correct again, else it goes faster if applied
if(move_x != 0 and move_y !=0){
move_x = (right - left) * 0.7;
move_y = (down - up) * 0.7;
}
move_and_collide(move_x, move_y, obj_Action_Box);
Hope that helps!
@@1upIndie Reducing it by 0.7 is not accurate with all lengths. Much easier to do it right by using a unit vector.
@@oldshiloh9061Not sure I get what you try to tell me here.
For example the result value of right - left can be -1, 0 or 1 (same goes for the other). That you can multiply by the actual speed value you want to set for your game (1, 5, 50). That if it is diagonal you can multiply again by 0.7 (it is 0,7071067811865 if you want to be ultra precise, cosinus of 45 degrees).
var speedSet = 5; // the length/speed value how fast to move forward/any direction
var move_x = (right - left) * speedSet;
var move_y = (down - up) * speedSet;
if(move_x != 0 and move_y !=0){
move_x = (right - left) * speedSet * 0.7;
move_y = (down - up) * speedSet * 0.7;
}
Was that what you were looking for?
@@1upIndie I am telling you that the correct way to do it is to use a unit vector. It is more accurate and works for all angles. If you think that redoing a square root (only when the direction changes) is going to slow down your game, you are wrong. Your 0.7 is assuming that it is always using the square root of 2, and this is wrong. You are avoiding the correct solution for no reason at all.
@@oldshiloh9061Hm, then then answer is: No. Move and collide does not use vectors and it is a simplified way to create 2D movement. I do understand that vectors are faster and the standard for Unity/Godot/Unreal but not in GameMaker. Can you do vector movement? Yes, but you have to do by hand then and there are no functions (at least in my knowledge, correct me if I am wrong) in GameMaker to automate that. Godot does have move and collide also but is used different, with velocity * delta for 2D space.
Check out DragoniteSpam, he does use GameMaker with 3D functionalities in mind and maybe has the answer you are looking for or ask the pros in the GameMaker discord directly.
This video does cover the topic:
ua-cam.com/video/7ny19lk52RU/v-deo.html
Thanks for the undertale tutorial. hope this series wont take long to upload
Well, I have to go with small chunks, else this could be done in around 5 sessions. Nobody (at least for my videos and not tutorials in general) watches videos longer then 10min.
Code from the player Heat object's step event:
// get input from the keyboard and store in variables
var right = keyboard_check(vk_right) or keyboard_check( ord("D"));
var left = keyboard_check(vk_left ) or keyboard_check( ord("A"));
var up = keyboard_check(vk_up ) or keyboard_check( ord("W"));
var down = keyboard_check(vk_down ) or keyboard_check( ord("S"));
// get horizontal/vertical movement and store in variables, use a multiplier (2) to speed up
var move_x = (right - left) * 2;
var move_y = (down - up) * 2;
// use the move_and_collide function to auto move the player heart instance
move_and_collide(move_x, move_y, obj_Action_Box);
Seems simple... so far 😅
So far yes :D