From the course: Building a Physics-Based Platformer in GameMaker Studio Using GML
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Collision checking with the ground - GameMaker Tutorial
From the course: Building a Physics-Based Platformer in GameMaker Studio Using GML
Collision checking with the ground
- [Instructor] Let's open up the player object, and transition from the jump state back into the run state. The easiest way to do this is to check to see if we've collided with the ground, once we're in the jump state. So, let's open up our collision with our static parent, which includes the floor object. Now, let's drag some code in there. I'll do a triple slash comment, and say floor checking. So, when we collide with the floor, the first thing we wanna do is check and see if we're in the jump state. So, let's check our state player variable, and if the current state is equal to our jump state, then we wanna transition back into the run state. Simple enough. I'll close this out. Since we now have some code in this event, I can remove the comment that we added earlier. I'll close out the player object. And if we run our game, we'll see that we have an issue. We'll start our player running. And jump. You notice that for some reason, the animation isn't correct. It's a very subtle…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Create the player object2m 48s
-
Using Finite State Machines1m 38s
-
Player state machine3m 16s
-
Control logic: Idle to run state2m 5s
-
Control logic: Idle and run animations2m 38s
-
Control logic: Jump state3m 50s
-
Control logic: Rotation and animation2m 46s
-
Collision checking with the ground3m 49s
-
Make the player duck3m 57s
-
View following and debug3m 18s
-
Create physics fixtures in code6m 48s
-
Swap fixtures4m 3s
-
-
-
-
-
-