AbdatyK
Member
Hello, I'm relatively new to GameMaker so I'm trying to follow along a youtube tutorial by HeartBeast (found here). I'm aware that he's using an outdated version of GameMaker but I've been able to get by using the manual to fill in the gaps. What I'm stuck on is the damage object that is initialized when the player begins his attack animation. From what I understand, what makes the collision event be called one time instead of each step is marking the damage object as a sensor. However, checking the sensor box didn't work so my enemies are being killed in one hit since the damage is being applied so many times. My room and objects all use physics, and I even tried making a fixture and assigning it to the damage object in its create event, but it still doesn't act as a sensor object.
This is the code that is in the create event of my damage object.
This code is in the collision event of the damage object, when colliding with a lifeform object which is the parent of my enemies and player.
I'm using version 2.3.4.580
Thank you all in advance
This is the code that is in the create event of my damage object.
GML:
// Sets the damage referenced in the collision event
damage = 1;
creator = noone;
// Creates a fixture and binds it to the damage object
var fixture = physics_fixture_create();
physics_fixture_set_box_shape(fixture, sprite_width/2, sprite_height/2);
physics_fixture_set_density(fixture, 0.5);
physics_fixture_set_restitution(fixture, 0.2);
physics_fixture_set_friction(fixture, 0.5);
physics_fixture_set_sensor(fixture, 1);
physics_fixture_bind(fixture, obj_damage);
GML:
// Damages the other object if the object is not the one attacking
if (other.id != creator) {
other.hp -= damage
}
// Sets an alarm to destroy the instance
alarm[0] = 1;
Thank you all in advance