G
Gronbal
Guest
Hi, so I'm in the progress of trying to master the Gamer Maker 2 programming language. Recently I stumbled across a little problem. What I'm trying to accomplish, is moving an item object to the center of another object, whereafter a series of events will trigger when the two objects are on top of eachother.
My item object is a multipurpose object, that can take shape and form of every item in the game, e.g armor, weapons and relics. To do this I use a variable called item_num which will determine what item it will be based on the integer assignet to it.
I'm therefore looking for a specific value in the variable item_num, and if that value is found, I will proceed to move the object. The problem is that the item isn't moved, If I drop another object, then remove it, then the right item object will move. First I thought this could have been caused by the object not being found if it was dropped, but by using show_debug_message() I could see that it indeed did run the code when the value was met.
My code is down below, and I hope you genius' can help me find a solution.
My item object is a multipurpose object, that can take shape and form of every item in the game, e.g armor, weapons and relics. To do this I use a variable called item_num which will determine what item it will be based on the integer assignet to it.
I'm therefore looking for a specific value in the variable item_num, and if that value is found, I will proceed to move the object. The problem is that the item isn't moved, If I drop another object, then remove it, then the right item object will move. First I thought this could have been caused by the object not being found if it was dropped, but by using show_debug_message() I could see that it indeed did run the code when the value was met.
My code is down below, and I hope you genius' can help me find a solution.
Code:
//Sets the temporary variable item_id to be the id of object_item, if it is in the collision range
var item_id = collision_circle(x, y, 200, obj_item, false, true);
//Checks to see if the variable item_num is the right value.
if(variable_instance_get(item_id,"item_num") = item.relic) {
with(item_id){
//Set some temporary variables
var npc_x, npc_y, hspd, vspd, len, dir;
npc_x = other.x;
npc_y = other.y;
//Get the length and direction
dir = point_direction(x, y, npc_x, npc_y);
len = spd;
// Get the hspd and vspd
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);
// Move the item object
phy_position_x += hspd;
phy_position_y += vspd;
}
}
Last edited by a moderator: