Dr_Nomz
Member
Code:
if place_meeting(x,y,obj_Barricade_1) && attack=0{
audio_play_sound(snd_Empty,100,false);
with (other){
HP-=1;
}
attack=1;
//instance_destroy();
}
if place_meeting(x,y,obj_Barricade_1) && attack=0{
audio_play_sound(snd_Empty,100,false);
with (other){
HP-=1;
}
attack=1;
//instance_destroy();
}
// With
with obj_player {
health -= other.damage; // Player's 'health' minus our 'damage'.
}
// Collision event:
// (In a collision)
with other { // With the instance we're colliding with.
health -= self.damage; // Other's health minus our 'damage'.
}
var _inst = collision_point(x, y,obj_Barricade_1, false, false);
if instance_exists(_inst) && !(attack) {
audio_play_sound(snd_Empty,100,false);
with (_inst){
HP--; // You get the idea.
}
}
You should know there is an instance-ID-oriented true equivalent to place_meeting(), and it's instance_place(), not collision_rectangle().For this case, you'll either want to go to the Collision Event (lame imo), or do the instance capturing process yourself. For that, you need more than a bool check like 'place_meeting'. I usually use 'collision_rectangle', which lets you define a boundary for the collision, but you can also use 'collision_point' - as long as the function returns the id of the collided instance, you're good.
Yep, that's the one. Either way, the point still stands - 'other' doesn't work in this case.You should know there is an instance-ID-oriented true equivalent to place_meeting(), and it's instance_place(), not collision_rectangle().
if place_meeting(x,y,obj_Barricade_1) && attack=0{
audio_play_sound(snd_Empty,100,false);
with (instance_place(x,y,obj_Barricade_1)){
HP-=1;
}
attack=1;
//instance_destroy();
}