Dobra zrobiłem tak, ale teraz jak skocze przytrzymam shift i jak postać dotknie już podłogi to się zacina nie wiadomo czemu, chodzi normalnie, ale jak chce biegnąć to stoi w miejscu.
Step:
GML
if place_free(x,y+1)
{gravity = 0.5}
else
{gravity = 0}
if keyboard_check(vk_right) & place_free(x+5,y)
if keyboard_check(vk_shift)
{sprite_index=spr_run_right
x+=8}
else
{sprite_index=spr_walk_right
image_speed=0.8
x+=5
}
if keyboard_check(vk_left) & place_free(x-5,y)
if keyboard_check(vk_shift)
{sprite_index=spr_run_right
x-=8}
else
{sprite_index=spr_walk_right
image_speed=0.8
x-=5
}
if keyboard_check_released(vk_left)
{
sprite_index=spr_stance_right
}
if keyboard_check_released(vk_right)
{
sprite_index=spr_stance_right
}
if gravity = 0
{
if keyboard_check_released(vk_right) sprite_index = spr_stance_right
if keyboard_check_released(vk_left) sprite_index = spr_stance_left
}
if keyboard_check(vk_space) & not place_free(x+0,y+1)
{
if sprite_index = spr_stance_right & image_xscale=-1 sprite_index = spr_jump_right & image_xscale=-1
if sprite_index = spr_stance_right sprite_index = spr_jump_right
if sprite_index = spr_walk_right & image_xscale=-1 sprite_index = spr_jump_right & image_xscale=-1
if sprite_index = spr_walk_right sprite_index = spr_jump_right
if sprite_index = spr_run_right sprite_index = spr_jump_right
if sprite_index = spr_walk_right & image_xscale=-1 sprite_index = spr_jump_right & image_xscale=-1
vspeed=-10;
}
if place_free(x,y+1)
{
if keyboard_check(vk_left) sprite_index=spr_jump_right
if keyboard_check(vk_right) sprite_index=spr_jump_right
}
if sprite_index = spr_jump_right
{
if keyboard_check_pressed(vk_left) image_xscale=-1
if keyboard_check_pressed(vk_right) image_xscale=1
}
if sprite_index = spr_stance_right
{
if keyboard_check_pressed(vk_left) image_xscale=-1
if keyboard_check_pressed(vk_right) image_xscale=1
}
if sprite_index = spr_run_right
{
if keyboard_check_pressed(vk_left) image_xscale=-1
if keyboard_check_pressed(vk_right) image_xscale=1
}
if sprite_index = spr_walk_right
{
if keyboard_check_pressed(vk_left) image_xscale=-1
if keyboard_check_pressed(vk_right) image_xscale=1
}
Kolizja z blokiem:
GML
move_contact_solid(270,4)
vspeed = 0
if sprite_index = spr_jump_right sprite_index =spr_stance_right
if sprite_index = spr_jump_right & image_xscale=-1 sprite_index =spr_stance_right & image_xscale=-1
Zobaczcie, w tym przykładzie to jak ląduje dziwnie wbija się w ziemie,
https://gmclan.org/up4796_4_Assasin_Creed.html