Simple Gravity and Variable Jump | 60 Second Code | GameMaker studio 2

preview_player
Показать описание
Music -Psalm Trees, Guillaume Muschalle - Peninsula
Рекомендации по теме
Комментарии
Автор

Thanks, I even added double jump by making grounded = 2 if touching solid block, after one jump grounded -= 1 and to be
able to jump just grounded > 0, but you have to delete "else" in a vertical collision.

bunthasmatulko
Автор

Thank you !! Please put out more gamemaker content!

wrdsandstuff
Автор

Thank you!!!! It works great, but my character won't move horizontally, only jump. It also only jumps if I hold down D or A. Is there any way you could help?
It would mean a lot to me!

hunee_yt
Автор

Hi. I tried this and it mostly works, but I came across an issue

when I press the jump key, the character teleports up to the peak of the jump and then falls.

is there any way to fix this?

turtleslurper
Автор

so this works great for one object im colliding with, but what do i do when i want another block i want to jump off of, i made a stone and a grass block, what do i do to jump from the second object, just copying the code and filling in the other object doesnt work. can you tell me a way how the code has to look like?

maniacdoc
Автор

This is great but, how would I modify the speed of the jump while keeping the max jump height the same?

dahorrorazguy
Автор

This works when i use "W" as the jump key but stops working when i use vk_space. Is there a way to make space the jump jey?

abdullahismail
Автор

jump buffering dosent work and
when i make a small jump the gravity is faster
how do you fix that?

weebinit
Автор

My character doesn't jump so high, when I press W the character jumps but the gravity attracts her to the ground fast.

AbdullahSenpai
Автор

I just code my character to move horizontally and without vsp, so can I use the same code as the video above?

hoangtaipham
Автор

quick question, do i have to name the variables in my variable definitions for my code to work?

OmartheScientific
Автор

It works, but i cant move left or right, only jump, did i do something wrong?

doggoandyeet
Автор

personally whenever I add "grv" to the code, somehow the game just won't show up anymore, the game loads but there's no way to actually play it... All tutorials ends up doing it and no meaningful answer to my concern on the internet... Like I'm somehow the only one that got this issue... it's horrible...
And no it can't be a loop issue I tried other codes that didn't include "grv" anywhere and it works perfectly! So why??

BlazeStar
Автор

The jump is consistent for me. When I tap it or hold it goes the same height how do I fix that

respawntrooper
Автор

my plr object sinks into the ground by a few pixels sometimes when it lands

zacaultim
Автор

I'm making a sonic game with this, and his animation wont stop when i let go of the keys after moving for atleast 1 second but when I tap a key very quickly it'll stop. And it also won't jump.

Step event:
kjump =
kholdjump = keyboard_check(ord("z"));
kdown = keyboard_check(vk_down);
kright = keyboard_check(vk_right);
kleft = keyboard_check(vk_left);

if kright
{
sprite_index = spr_sonicwalk
image_xscale = 1
last_dir = kright
}
if kleft
{
sprite_index = spr_sonicwalk
image_xscale = -1
last_dir = kleft
}
if hsp == 0 && vsp == 0 && last_dir == kright
{
sprite_index = spr_sonicidle
image_xscale = 1
}
if hsp == 0 && vsp == 0 && last_dir == kleft
{
sprite_index = spr_sonicidle
image_xscale = -1
}

var hmove = kright - kleft

if hmove != 0
{
if last_h != hmove
{
last_h = hmove
acc_fn = 0
}

if acc_fn <= acc_max
{
acc_fn += acc
}
}
else
{
if acc_fn > 0
{
acc_fn -= acc
}
}
if acc_fn < acc
{
acc_fn = 0
last_h = 0
}

if kjump == 1 and grounded == 1
{
vsp += jump
sprite_index = spr_sonicjump
}
if vsp < 0 and (!kholdjump)
{
vsp = max(vsp, jump / jump_mod)
}

vsp += grv

vsp = clamp(vsp, -vsp_max, vsp_max)

if (place_meeting(x + hsp, y, obj_collisionblock))

if (place_meeting(x, y + vsp, obj_collisionblock))
{
while (!place_meeting(x, y + sign(vsp), obj_collisionblock))
{
y = y + sign(vsp)
}
grounded = 1
vsp = 0
}
else
{
grounded = 0
}

hsp = acc_fn * last_h

x += hsp;
y += vsp;

iey
Автор

and why cant i move and why do i need to prees "a + w" to jump

masahiruQwQ
Автор

Great Video but when the player jumps under a block and you hold W it sticks to it, is there a way to stop that?

AlfredMortensen
Автор

hi, first of all, your videos are helping me a lot, but, my code is not working, the character is getting stuck on walls and can't walk, could you please help me?

ferromaster
Автор

How do I add multiple jumps to this, Like a double or triple jump.

poplaso