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.
Make the player duck - GameMaker Tutorial
From the course: Building a Physics-Based Platformer in GameMaker Studio Using GML
Make the player duck
- [Instructor] The next thing we want to do is make our player duck when we press the down arrow, stop ducking when we release the down arrow, and we also want to enable our player to jump from the duck state. So let's get that going. Let's first create a couple scripts. I'll go to the script folder, and say Create Script, and we'll use this script to check for the down arrow being pressed, and move our player into the duck state. So I'll call it sc for script, underscore duck. I'll give it a comment, call it ducking, and we say if, we'll check for a keyboard press. And here we want to check for the down arrow, so we'll use vk_down. That's GameMaker's built-in variable for the down arrow key. A couple brackets, and since we're using our state machine architecture, we simply have to take our current state variable, and change it to our new state variable of ps.duck. We can also take this opportunity to set the sprite index, so let's take our current sprite_index, and set it to our…
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
-
-
-
-
-
-