• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

GameMaker (résolus ) no loss of life with collision

D

diester

Guest
Hello,
after being confronted with too much collision problem I recommed
I made my new project by basing on this tutorial:



all goes well at the level of collisions between the player's walls and the o_solid object that is destroyed by a bomb.

the problem is that my character does not lose his life if he enters in collision with the explosion of the bomb when he should.

however, I use the basic system:

to define the life of the player in script scr_InitializePlayer:

Code:
jumpKey  = global.jumpKey;
rightKey = global.moveRightKey;
leftKey  = global.moveLeftKey;
shootKey = global.shootGunKey;

max_health_ = 25;
health_ = max_health_;
maxRunSpeed  = 4.8;
maxFallSpeed = 12;
maxJetSpeed  = 4;

xSpeed = 0;
ySpeed = 0;

frict = .2;
accel = .4;

weight    = .5;
jetPower  = .12;
jumpPower = 10;

vertState = verticalstate.onGround;
in collision obj_ boom ( who is the explosion ) in oPlayer :

Code:
health_ -= 5;
in step oPlayer :

Code:
if (health_ <=0)
{
    instance_destroy(bb)
    game_restart();
}
I create a life bar that does not go down because the collision is not made.

Code:
draw_self();

if !instance_exists(oPlayer) exit;

draw_health_ = lerp(draw_health_, oPlayer.health_, .25);

draw_set_color(c_red);
draw_rectangle(x+4, y+4, x+123*draw_health_/oPlayer.max_health_, y+11, false);
draw_set_color(c_white);
the collisions are well defined in each sprite.

I check if this was a problem of layer but I think rather a conflict with the scripts ???

Any ideas
 
Last edited by a moderator:
D

diester

Guest
I answer myself because after a search and reflection I found the execution path. but I have a timer problem.

in the script "scr_UpdatePlayerMovement" which corresponds to step of the object oPlayer I add:

Code:
if place_meeting(x, y, obj_boom)
  {
    
     timer -= 1;

if(timer == 0)
{
   health_ -=  5;
   invincible_ = true;
     }
invincible_ = false;
}
the player loses life, what I wish is that oPlayer is invincible for a second and loses only 5 of life (otherwise it dies because the collision is chained for a few seconds as the explosion lasts 3 seconds).

but the player remains invincible ...........

or have I made a mistake ??
 
Top