Windows [Solved ] Help with a Collision "Exception"

M

Marc_IceBlade

Guest
Hello, I have only picked up Gamemaker yesterday and I started to make my own game, which is basically a Top-Down, Puzzle like game. This includes the Player being able to throw Knives in order to kill guards, however I am struggling with a certain feature that has to do with the Knife. I now want to make an Arrow Slit block, which the player can't walk through but the Knife can fly through. This is my movement code for the player:
Code:
key_right = keyboard_check(vk_right);
key_left = keyboard_check(vk_left);
key_down = keyboard_check(vk_down);
key_up = keyboard_check(vk_up);

if(key_right && !place_meeting(x + 2, y, Obj_Block_1))
{
   x += 2;
   image_angle = 90
}
if(key_left && !place_meeting(x - 2, y, Obj_Block_1))
{
   x -= 2;
   image_angle = 270
}
if(key_down && !place_meeting(x, y + 2, Obj_Block_1))
{
   y += 2;
   image_angle = 360
}
if(key_up && !place_meeting(x, y - 2, Obj_Block_1))
{
   y -= 2;
   image_angle = 180
}
Now as you can see it checks for the Object "Block-1" and I set that Block as a parent for everything that the player is not allowed to move through. It works flawlessly for most things I am trying to make, however the Knife detection works similarly, which means it checks if there is the Obj_Block_1 and if it hits it, it gets destroyed as it isn't supposed to fly through a wall. But is there a way so that I can make Obj_Arrow_Slit an expection?
Also I already tried setting collision Masks and checking for them, however that resulted in less fluid movement and the player slowly drifted through the Arrow_Slit.
I appreciate any help I can get, if you require more code just tell me.

Marc
 
M

Marc_IceBlade

Guest
Could you please elaborate a bit more on that? If I give Arrow Slit another parent, the Player can move through it, which is unwanted.
 

Paskaler

Member
If you destroy the knife in the collision event, add this check:

Code:
if other.object_index == Obj_Arrow_Slit {
     exit;
}

instance_destroy();
 
Top