jaaldis
Member
Hey - So I've basically got a shop room which has three podiums. When I enter the room, an item instance (oShopItems) is randomly generated onto each podium. There are three similar chunks of code to generate each item, which look like this:
Now, what I want to do is have a trigger object in front of each podium (oBuyObject) which, when I press enter, will destroy the instance that corresponds with the podium its nearest to. I've tried using instance_nearest, tried using a collision_rectangle and collision_point variables but every time it just destroys all three instances. Any help would be much appreciated!
GML:
if room = rStuffPlaceInterior {
var shop1 = collision_rectangle(280, 200, 318, 220, oShopItems, true, true)
if shop1 = noone && global.storeClosed = false && (!shopItems) {
var Obj1 = instance_create_depth(300, 211, 100, oShopItems);
with (Obj1)
{
DrawHereX = 300
DrawHereY = 211
DrawObjectType = DrawWallObjs
}
shopItems = true;
}}
if room = rStuffPlaceInterior {
var shop2 = collision_rectangle(240, 247, 286, 268, oShopItems, true, true)
if shop2 = noone && global.storeClosed = false && (!shopItems1) {
var Obj2 = instance_create_depth(262, 255, 100, oShopItems);
shopItems1 = true;
with (Obj2)
{
DrawHereX = 262
DrawHereY = 255
DrawObjectType = DrawLargeObjs
}
}}
if room = rStuffPlaceInterior {
var shop3 = collision_rectangle(315, 247, 336, 266, oShopItems, true, true)
if shop3 = noone && global.storeClosed = false && (!shopItems2) {
var Obj3 = instance_create_depth(325, 255, 100, oShopItems);
shopItems2 = true;
with (Obj3)
{
DrawHereX = 325
DrawHereY = 255
DrawObjectType = DrawSmallObjs
}
}
}