GMS: How to Move on Steps & Slopes? (Over View)

Channel:
Subscribers:
268
Published on ● Video Link: https://www.youtube.com/watch?v=dQNWng_vdh4



Duration: 5:09
37 views
3


GMS File: https://bit.ly/3dQQwS3

Note: Not shown on video, be sure collision mask for player is a "Ellipse" NOT a Rectangle or Precise. This is due to moving up the Steps and Slopes.

Note: Be sure to parent obj_player_left with obj_player_right.

obj_player_right

Events:

Create

Actions:

///movement variables
m_speed = 10;
m_step = 5;

vspeed = 0;

m_gravity = 1 ///Jump in air
m_jump = -15;


Events:

End Step

Actions:

////movements
vspeed += m_gravity; ///allows to jump in air moving right or left


if keyboard_check(vk_left)
{
move_contact_solid(90, m_step);
move_contact_solid(180, m_step);
move_contact_solid(270, m_step);

}

if keyboard_check(vk_right)
{
move_contact_solid(90, m_step);
move_contact_solid(0, m_step);
move_contact_solid(270, m_step);
}
if keyboard_check_pressed(vk_up) ///jump in air moving right or left
if !place_free(x,y+1)
{
vspeed = m_jump;
}


Events:

Collision with obj_block, check solid ///Check solid for slopes too.

Actions:

vspeed = 0;


Events:

Collision with obj_right_slope

Actions:

vspeed = 0;
move_contact_solid(270,20);

Events:

Collision with obj_left_slope

Actions:

vspeed = 0;
move_contact_solid(270,20);







Tags:
how
learn
teach
find
player
code
create
object
sprite
game
maker
room
if
place
set
get
draw
studio
back
ground
image
drop
change
computer
pc
android
device
collision
var
variable
step
up
down
jump
left
right
meeting
index
speed
gravity
free
keyboard
solid
move
contact
mask
shortcut
slope
block
steps
vspeed
amount
ellipse
modify
m_step
direction
dir
air
meet