GML Hitbox Doesn't Work

B

Bengs

Guest
So ive made a character and a hitbox and then put in collission code between my hitbox and my enemy but it appears i made a mistake. Can anyone help me?

My attack code is
Code:
            hsp = 0;
            x = x + hsp;
            image_speed = 2;
            sprite_index = Spr_CharacterAttack01Right;
            instance_create_layer(x,y,Obj_Character,Obj_CharacterAttack01RightHitbox);
            if (image_index > image_number - 1){
            attack = 0;
            }
and then in the obj_hitbox it's collission code with the enemy this code
Code:
with other{
    Ehp -= Obj_Character.Cdmg;
    }
    instance_destroy(Obj_CharacterAttack01RightHitbox)
In my character create code i put
Code:
Cdmg= 50;
In my enemy create code i put
Code:
Ehp = 100;
I also put this in my enemy step code

Code:
if Ehp <= 0 {
instance_destroy()
}
 

Rob

Member
How are you checking for collision? It's your collision code that's going to make it work or not.
 

Rob

Member
Whithin my hitbox i made a collission event between my hitbox and enemy
Sorry I'm still waking up :p

I don't see what's stopping it working at the moment. Try putting the collision code in the enemy and making a parent object for all of your hitboxes?

I know it's probably difficult for you but try and work towards having just 1 hitbox and using the step event + collision_rectangle to check for collisions. It will help you along your programming journey.
 
B

Bengs

Guest
Sorry I'm still waking up :p

I don't see what's stopping it working at the moment. Try putting the collision code in the enemy and making a parent object for all of your hitboxes?

I know it's probably difficult for you but try and work towards having just 1 hitbox and using the step event + collision_rectangle to check for collisions. It will help you along your programming journey.
Still waking up.. its 20:20 over here xD.
Did try it but didnt work :( still ty though
 
B

Bengs

Guest
Sorry I'm still waking up :p

I don't see what's stopping it working at the moment. Try putting the collision code in the enemy and making a parent object for all of your hitboxes?

I know it's probably difficult for you but try and work towards having just 1 hitbox and using the step event + collision_rectangle to check for collisions. It will help you along your programming journey.
I discoverd a solution apparently it couldnt find Cdmg or something so i just changed the collission code to
Code:
 with other {
Ehp -= 50;
}
 
Top