M
MechaMonst3r
Guest
Hey! I'm decently new to Game Maker Studio 2, and GML as a programming language but not unfamiliar with programming it's self (I'm a second year Computer Science student). Anyways, I'm attempting to make my first game and I'm having some issues with collision detection when picking up the item object. In-game the item will play the sprite and depending on what image index it's on will depend on what item will appear in your Item UI and what effect it does. Now: When you first start the game, your player can collide with the item and it appears in your Item UI. You can the press Space to "use" the item, the item disappears and the effect on the Player takes hold. All is well; until the Player collides with another item. This time the collision does not register at all and it just passes through the Player completely... and every item after that does the same. I have no idea why this is happening, I scoured my UI code and Item code that handles everything and I can't figure it out for the life of me. So I'm hoping you guys have some answers for me!
Code for the item Step Event that handles collision with the Player:
Code for Step Event for the UI for Items:
Please excuse any rookie mistakes I have made, and thank you in advance!
Code for the item Step Event that handles collision with the Player:
Code:
direction = 180;
speed = 4*global.comboSpeed;
if(place_meeting(x - 1, y, obj_player))
{
if(image_index = 0)
{
global.is_red_item = true;
global.is_green_item = false;
global.is_blue_item = false;
global.have_item = true;
instance_destroy(self);
}
if(image_index = 1)
{
global.is_green_item = true;
global.is_blue_item = false;
global.is_red_item = false;
global.have_item = true;
instance_destroy(self);
}
if(image_index = 2)
{
global.is_blue_item = true;
global.is_red_item = false;
global.is_green_item = false;
global.have_item = true;
instance_destroy(self);
}
}
Code:
if(global.have_item = false)
{
obj_item_hud.visible = false;
}
if(global.have_item = true)
{
if(global.is_blue_item = true)
{
image_index = 2;
obj_item_hud.visible = true;
if(global.using_item)
{
alarm[0] = 5;
global.use_blue_item = true;
global.use_green_item = false;
global.use_red_item = false;
global.have_item = false;
}
}
if(global.is_green_item = true)
{
image_index = 1;
obj_item_hud.visible = true;
if(global.using_item = true)
{
global.use_green_item = true;
global.use_blue_item = false;
global.use_red_item = false;
global.have_item = false;
}
}
if(global.is_red_item = true)
{
image_index = 0;
obj_item_hud.visible = true;
if(global.using_item = true)
{
alarm[1] = 5;
global.use_red_item = true;
global.use_blue_item = false;
global.use_green_item = false;
global.have_item = false;
}
}
}