Це відео не доступне.
Перепрошуємо.
How to Move and Collide in GameMaker
Вставка
- Опубліковано 7 чер 2023
- This tutorial teaches you the easiest way to move in GameMaker, with proper collisions, and it only takes a few minutes to set up.
Get the sprites: yoyo-www-cms.s...
Read the blog: gamemaker.io/e...
Need help? Join our Discord: / discord
This tutorial works for GameMaker 2023.1 and newer. If you use an older version of GameMaker, check out:
👾Platformer: ua-cam.com/video/XaaLgOOFxAw/v-deo.html
👾Top Down: ua-cam.com/video/oqYyD4KB7pw/v-deo.html
The function to replace 70% of game maker tutorials.
Anyway to code it with earlier versions of gamemaker studio?
@@TheRealLifeSonicTheHedgehog read the pinned comment
In case anyone's having problems with moving - try setting both the "Max X Movement" and the "Max Y Movement" in Move and Collide to "-1". This should fix the issue. Shoutout to Mimpy for figuring this out :)
Thank you and Mimpy again!
do you know how to do that in code?
they were set to -1 and my dumbass turned them to 0 because of tutorial well thanks for this!
@@hairo4242
Where
@@hairo4242 same, thought it was suppsoed to be 0 before even testing it
i did everything exactly the same, but i cannot make it past the debugger.
This is very useful, I've once looked for a tutorial about this, but I'm at a loss, with this function I will be greatly helped
infinitely more helpful than the gamemaker code videos. Thank you man.
Finally, after all these years.... the horror...
so cool that you show BOTH ways GML and GMV,, just awesome!
Its gamemaker oficial chanell
@@phel7369 yes, correct 😄
In case anyone else made the same mistake as I did, make sure when your player object is not moving, that you didn't overlap their frame into the wall object frame or it will not move at all. I simply dragged it out of the overlapping frame and it could move.
Thank you so so much! 🙏
That just solved the problem for me after I`ve tried so many different codes from different tutorials and nothing worked.
thank you
AFTER A FEW HOURS OF TRYING TO DO IT BY WATCHING OTHER TUTORIALS- I FINALLY DID IT..
i feel represented
Why are you not using a unit vector to calculate proper movement? The way you are moving will make you move faster diagonally, so it is not the correct way to do it at all. Why not explain the proper way to do movement? For example:
// Get player input
var keyLeft = keyboard_check(vk_left) || keyboard_check(ord("A"));
var keyRight = keyboard_check(vk_right) || keyboard_check(ord("D"));
var keyUp = keyboard_check(vk_up) || keyboard_check(ord("W"));
var keyDown = keyboard_check(vk_down) || keyboard_check(ord("S"));
// Determine input direction and magnitude
var inputDirection = point_direction(0,0,keyRight-keyLeft,keyDown-keyUp);
var inputMagnitude = (keyRight-keyLeft != 0) || (keyDown-keyUp != 0);
// Calculate our movement vector (the proper way so that diagonal movement does not exceed our walk speed!)
hSpeed = lengthdir_x(inputMagnitude * speedWalk, inputDirection);
vSpeed = lengthdir_y(inputMagnitude * speedWalk, inputDirection);
// Move the character
x += hSpeed
y += vSpeed;
Das hat mir sehr geholfen.
Genau das was ich gebraucht habe 🙏🙏🤓
I just have a sprite and a white background. sprite is not moving after copying this video. any ideas?
Hey👋how can i apply the collison code to work properly with movement that has acceration and decceration? im moving faster at angle then if i were moving straight.
Help, when I run into the walls i don't collide but I just slow down while I rub trough them. Does someone know how to fix this?
same happened to me
Two questions
How to make this work with tileset collision
How to make this work with advanced 8-way movement (the movement in the manual that prevents faster movement via diagonal movement)
dont do tileset colision, do 1 obj to have the colision and use it everywhere u want to, to make it invisible just do the step code image_alpha = 0;
1:42 Is... Is that really the visual/not-code version? How is that not code? I am so lost...
The left side is visual coding and the right side is just text coding code lol
best tutorial i have ever seen now i know how to code thx
Great! Glad you enjoyed it :).
Thanks great video
Move_and_collide must be one of the most convenient functions when it comes to movement
idk why but its not working, can someone help me?
move_and_collide doesn't appear. What should i do?
would be great if this went into more depth on how to pair this with actual platformer movement like jumping and gravity so you're not just floating in space. As is, it seems it would be better for top down style movement. I'm figuring out myself to see how it also works with place_meeting collision and what not. Not really complaining, just stating it would have been nice to see more out of this like your other tutorials. Thanks for getting the gears turning on how to use this function!
ye this is like a survival style game, but would work the same when in platformer i think, just look up platformer tutorial
is anyone encountering an issue where theyre following all the same steps, but when it comes time to run the game they keep getting the same error?
"Object: obj_player Event: Step at line 6: Cannot set a constant ("right") to a value
Object: obj_player Event: Step at line 13: Cannot set a constant ("left") to a value"
im using gml visual
Yes bruh 💀
dude..... this fix is needed asap
i think its cuz you have to set the var as _right not right, like "right" is already a preset variable with a constant value
How would I make this work but with tile maps instead of objects? and only colliding with the actual pixels of the tiles instead of the whole square?
I'm building a new game (first one) and followed this guide, but when my player object hits the right wall, I can only get off of it by pressing left and down at the same time, and I can't move up at all. On the flip side, the left wall also traps my player, and I can only move away from it by pressing up and right at the same time.
💪 good luck on the first game! For the coding help the best place to go is the GM Community Forum or Discord
Forum: forum.gamemaker.io/index.php
Discord: discord.com/invite/gamemaker
How to stop character animation when he hits the wall?
Why am I getting stuck in walls?
Life Saver
I did this and now it just slows down when the player hits the wall, it doesnt stop. someone help
I still have issues with 1 pixel gap. how do i "fix this".
Change your character collision box to one pixel smaller
I have an odd issue with the corners, I just go straight through them - or infact any object I create after the main wall my character ignores collision.
How do you make diagonal movement same speed as moving into just 1 direction??
use the clamp code
is there any way to get this to work for multiple objects ¿ when i just add another object to move and collide it restricts me from moving , and when i copy and paste the move and collide it doubles my speed and i walk like sludge right through my objects . i cant create a new set because it just merges with the already existing set . am i missing something ¿
edit : figured while im at it id mention there are some points on diagonal walls where my character gets stuck , but i can still wiggle my way out if i turn back and forth and move up or down
When the movement speed is a decimal point, the screen shakes as the player moves.
How do I solve this part?
Lerp the camera following the object. Uses linear interpolation for the movement of the camera/camera object.
Why is my object automatically going to the right?
THANK YOU SO MUCH I REALLY APPRITIATE IT
YOU'RE MOST WELCOME :)
funny😂🤣🤣🤣🤣🤣🤣🤣🤣
What's the diference betwen this and use de colisión event for detect collisions with walls?
Does anyone know how to make it so that the diagonal angles go the same speed as the horizontal and vertical?
You can do that by calculating the direction of movement using point_direction(0, 0, x_input, y_input). Then put that into lengthdir_x() and lengthdir_y() as the direction, along with a speed as the length, and add the results to the X and Y variables respectively. This gives you a uniform speed in whatever direction you enter.
I'm still not able to move, even tho i did everything step by step. Is there something wrong?
I got movement down but I can’t get the collision to work, I walk through walls- help?
How can I use this method in a platform game?
2:29 I have this written as shown it’s not working can someone help me
Let’s go!
im making it it code and whenever i try to move it doesnt work
Hi like btw im from Indonesia but I have a question a GameMaker Can't create Game Genre simulators???
didnt work, can someone help me
How do you make this work with tilesets please?
I can’t get my sprite to spawn
im not sure what i did wrong but it isnt working
my guy goes to the right really fast and i cant control him, please help
the name of your variable for the characters walk speed is called "speed" make sure it is not green. try " _speed". Speed is already a prebuilt variable with constant value. So it is going to do some weird things.
@@bombardier1588I was so lost on the same issue, thanks man 👍
how do i make it so the player can,t move up and down and just left and right because move and collide doesn,t want to work that way
Did you get it?
@@GameMakerEngine i tried but it needs 3 arguments and it just doesn,t work i tried erasing var up and var down but then it doesn,t work
@@_Vonos_ Sorry it took a while to get back to you. You could try set the y component of your movement to zero, or you could follow the 5 min platformer tutorial: ua-cam.com/video/-5sBIUiutAk/v-deo.html
@@GameMakerEngine thx
What if you have multiple obj with collision.
Do you repeat move_and_collide and add the different obj
Or
You can use comma and continue adding obj in same?
Those objects should inherit from one object and then you use move_and_collide on that object.
@@Gamer-wj4qv I meant for different sprite in different object. Do you use move_and_collide (........, obj_1, obj_2, obj_3) to put different objects to get collision in one code or do you have to copy paste and just replace obj_1 with obj_2 and so on?
also I am pretty much learning from scratch so I have no idea. Just practicing as much as i can in free time.
I've run into the same issue
Yeah me too, if anybody has figured this out please let us know❤
@@samsungphone1326 look up a guide for "object collision parents" in gamemaker if you haven't figured it out yet.
So you have to have a Wall object in the room to move!
No tutorials that show how to move rooms work with this.
When i plress LMB+Alt it just moves my screen around
Had this same issue and I was getting extremely frustrated that nobody mentioned it. In case you haven't figured it out, Game Maker 2 has a "Laptop mode" that makes left-alt and right-alt have different functions. You can just use your right alt key. Or, to turn off laptop mode, the button for it is the laptop icon at the top (down-right of the "Source Control" menu on the menu bar)
How do I make it work with multiple objects
read fruitrsalad’s comment
followed the tutorial exactly but when I load the game it will not move the character
There seems to have been an update. Try setting both the "Max X Movement" and the "Max Y Movement" in Move and Collide to "-1". That fixed the issue for me!
@@entinoo thanks i'll try that
Does this work for older versions?
You need at least 2023.1
i cant move up or down
i did everything the same but my player wont move
There seems to have been an update. Try setting both the "Max X Movement" and the "Max Y Movement" in Move and Collide to "-1". That fixed it for me!
when i add other object then i can only move uo and down idk why can you help me?
The best place to go is the GM community forum or Discord
Forum: forum.gamemaker.io/index.php
Discord: discord.com/invite/gamemaker
It crashed
Can you make a version for 2d platformers?
Check the channel, the previous video is exactly that
oh !!!
Move and collide???? Is this new??
Sprites have been moving and colliding since before Seiklus, but this tutorial just shows off the newest fastest way to crash into walls.
Sorry didn't work for me idk
Is bro speaking france or english and is bro usain bolt💀
perdin sime sirvio
It didn’t work 😢
Mine does not run when I use this code
Oh, try using the debugger: ua-cam.com/video/rqSRmFT1I-U/v-deo.html
Another option would be to post in the community forum or Discord. The community are really helpful there:
Forum: forum.gamemaker.io/index.php
Discord: discord.com/invite/gamemaker
Didn’t work
I can’t fucking accept your cookies why?
what about npcs moving?
Hey, great question.
Here's a tutorial on how to make NPC's choose directions: ua-cam.com/video/8qUg_2CvD0k/v-deo.html
Here's a forum post about random movement: forum.gamemaker.io/index.php?threads/how-i-can-create-npc-movement-like-pokemon-red.21160/
no me sirvio tu momo
player wont move
Didn't work for me
What issue are you facing? Make sure you have updated to the latest version of GameMaker.
how do i fix this:
############################################################################################
ERROR in
action number 1
of Step Event0
for object obj_player:
Variable .right(100009, -2147483648) not set before reading it.
at gml_Object_obj_player_Step_0 (line 34) - var _xinput = right - left;
############################################################################################
gml_Object_obj_player_Step_0 (line 34)
how to fix
___________________________________________
############################################################################################
ERROR in
action number 1
of Step Event0
for object obj_player:
Variable .vkright(100004, -2147483648) not set before reading it.
at gml_Object_obj_player_Step_0 (line 1) - var _right = keyboard_check(vkright);
############################################################################################
gml_Object_obj_player_Step_0 (line 1)