GameMaker Studio 2: Complete Platformer Tutorial (Part 14: Dying )

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

If you notice there is a small bug that happens, right when you get hit and you press R to reset the game into the menu, your character will be very slow and laggy, the menu will be laggy too!
This happens because when you die the game speed hasn't been reset to 60 frames etc.


to fix this, you can go to oTransition object, and where the keybind says "Key Press R", or anywhere else where ever keybind R code is, just paste:

game_set_speed(60, gamespeed_fps);

So now right after dying and you press R, it shouldn't lag anymore!

ehanhassan
Автор

I added code to make the gun fly out of the player's hands when you die and spin around until it hits the ground. All you have to do is duplicate the oDead object, name it oGDead, and make the sprite the gun sprite. Go to the oPlayer object, into the collision event with oEnemy and add this code underneath the line
with (oGun) instance_destroy();

with(instance_create_layer(x, y, layer, oGDead))
{
hsp = lengthdir_x(3, direction);

vsp = lengthdir_y(3, direction)-2;
if (sign(hsp)!=0) image_xscale = sign(hsp);
}

(This is the same code to make the enemies fall when they die)

Then go to the oGDead object Step event and add the line
image_angle +=50;

It should be added underneath the line
vsp = vsp+grv;

So the first few lines will look like this
if (done==0)
{
vsp = vsp+grv;
image_angle +=50;
etc.

The number 50 can be changed higher to make the gun spin faster and lower to make it spin slower.

zaayid
Автор

if you want your gun to stay with your player after death, you could include it in the death sprite animation. Obviously it wouldn't be functional, but visually it'll still be there which is fun!

KickThePj
Автор

I did the slow mo with a global variable. Also slowed the animation, so enemies not only move slower horizontaly but also the animation is slower.
First tutorial where i didn't need to look at your code. Proude of myself :D Great stuff.

MadBunnyRabbit
Автор

Y E H A, I finally reached the newest episode of the whole tutorial series. This has been an awesome ride so far, and given me many new ways to approach stuff while coding. Thank you so much for all the care you put into this series, as soon as I got a job (university itself does not pay that well I am afraid :D) I'll join your patreons^^
Just one question, when will the next video come? as far as i gathered you upload them in a two week cycle normally (?) and it's been three weeks now, if YT is not lying to me^^

roundishwhale
Автор

Small adjustment I made:

My character now says "OH, MY GOD! whenever killed.

djk
Автор

i had a problem where they would just go into the ground after dying, but i realised it was because my origin point was set to top left instead of middle center. probably the 3rd time in this series thats happened lol

questionmarkquestionmarkques
Автор

Something you can add so that when colliding with larger enemies they don't push you straight into the ground:

vsp = lengthdir_y(4, direction) - (2 * other.size);

ljunderground
Автор

If your character dies and goes straight into the ground change the centre of origin for the player's dead body sprite from "Middle Centre" to "Bottom Centre" or to something like "16 x 29"

kieranclarke
Автор

Hey Shaun. Will you make a tutorial on pathfinding for this platformer? That would be great!

theodorjohansson
Автор

16:00 The animation speed of the enemies stay the same after you die. That's because you chose frames per second instead of frames per game frame. Choosing frames per game frame does have the downside that if the game slows down because your computer can't handle it (which almost never happens because it's a 2D game being able to run at thousands of frames per second), all the animations slow down too. Although for that to be a problem, you already have to change the movement speed of all objects to allow frame skipping instead of slowing down movements.

NaudVanDalen
Автор

Add this video to the playlist
I noticed it is missing 😊

Dilshad
Автор

Something changed, when I write other.x inside of the collision event with oEnemy the "other" does not reference the enemy, instead it references oPlayer

Edit: It only changes what's showing when you hover the mouse over "other", it still works just the same

MasochistNinja
Автор

Something you can do instead of changing the instance would be

if (hp <= 0)
{
with instance_create_layer(x, y, layer, oPDead)
{
image_xscale = oPlayer.image_xscale;
}
}
if (instance_exists(oPDead))
{
instance_destroy();
}

This makes it so that when you create the object, it is faces the same direction as oPlayer.
Putting "instance_destroy();" would destroy the player object before setting the "image_xscale" resulting in a crash.

PrimitiveAspid
Автор

Getting back into the saddle and trying to finish this series. I got to the sound tutorial and took a break, worked on a top-down arpg and then a top-down shooter on my own.

slimithy
Автор

is there a way to add lives? start with 3, and when it becomes 0 then the game resets

MaxNovOfficial
Автор

How do you add health so you don't get one shotted???

romanromero
Автор

thank you for great tutorial! but any chance to talk about more complex pattern for enemies? for examle enemy will randomly pick 1 from 3 move againt player. most tutorial I found on YT mostly teach about how to make control able character but not much about enemies.

TGHoly
Автор

with (oCamera) follow = other.id;
can simply be
oCamera.follow = id;
Otherwise you're changing the scope to oCamera and with other, you're changing the scope back, so you might as well use oCamera with a dot behind it. With is faster if you have to change multiple values of an object, but don't need to use other too much.

NaudVanDalen
Автор

My player was still keeping disappearing AFTER he collided the enemy - the "death animation" hasn't happened, the player just vanished. I was solving this problem many hours (there is actually no such issue, which would be discussed on the GMS forums), after I start to search among other game-making software, like Unity. And, I've got the answer, which solved the problem. So, if your character DISAPPEARS AFTER COLLISION, the solution is pretty simple and straightforward: in oPlayer "Collision with enemy" event, just DELETE instance_destroyed (); it actually doesn't make sense - you won't to play the death animation, not to destroy it (=vanish it). I'm quite surprised that it has worked in Shaun's video.
Thank you for your tutorials anyway, because it forces me to find the problem and solve it - it improves the skills with programming.

radobenito