R
Roobicorn
Guest
For some reason, instance_place isn't working even when position_meeting is.
I'm trying to set up interaction where hovering the mouse over an object (obj_shell) in the game will move another object (obj_main_menu) to the x location of that specific instance of obj_shell (there are 3 on the screen), and change the sprite of obj_main_menu based on a variable of that obj_shell.
here is the code I've got:
and here is the error message:
I've tried a lot of variations to see if that helps - changed shell_hover to var _shell_hover; adding an if (instance_exists(shell_hover)) statement below the shell_hover line. nothing seems to fix it.
if I change that line to obj_main_menu.x = 30; the error just happens on the next line down.
Any ideas why instance_place() isn't passing the id across?
I'm trying to set up interaction where hovering the mouse over an object (obj_shell) in the game will move another object (obj_main_menu) to the x location of that specific instance of obj_shell (there are 3 on the screen), and change the sprite of obj_main_menu based on a variable of that obj_shell.
here is the code I've got:
GML:
mouse_hover = position_meeting(mouse_x, mouse_y, obj_shell);
//...
if (mouse_hover)
{
shell_hover = instance_place(mouse_x, mouse_y, obj_shell);
obj_main_menu.x = shell_hover.x;
obj_main_menu.image_index = shell_hover.shell_pos; //default = 3 = blank image
}
shell_hover is defined as noone in the create event, and obj_main_menu exists, it just won't recognise that shell_hover has an instance id even when mouse_hover is true.Variable <unknown_object>.x(0, -2147483648) not set before reading it.
at gml_Object_obj_game_Step_0 (line 14) - obj_main_menu.x = shell_hover.x;
I've tried a lot of variations to see if that helps - changed shell_hover to var _shell_hover; adding an if (instance_exists(shell_hover)) statement below the shell_hover line. nothing seems to fix it.
if I change that line to obj_main_menu.x = 30; the error just happens on the next line down.
Any ideas why instance_place() isn't passing the id across?