GameMaker instance_position(xLocation,yLocation,all); returning 100099

D

Daniel O'Brien

Guest
For some reason instance_position(xLocation,yLocation,all) is returning 100099 instead of -4 (or noone) like it should. It appears that the first time the code is run it returns -4. However, the second time it returns 100099 which is not the ID of any object and causes issues further down the line.
My full code is
Code:
    temporary_id = instance_position(x,y+128,all);
    show_debug_message(instance_position(x,y+128,all));
    if(temporary_id == noone) {
       yGoal=y;
      xGoal=x+128;
      moving = true;
    }
This code is within a 'step' event
 

The-any-Key

Member
Check what it is:
Code:
temporary_id = instance_position(x,y+128,all);
if temporary_id>-1
{
    show_debug_message(string(object_get_name(temporary_id.object_index)))
}
 
D

Daniel O'Brien

Guest
Check what it is:
Code:
temporary_id = instance_position(x,y+128,all);
if temporary_id>-1
{
    show_debug_message(string(object_get_name(temporary_id.object_index)))
}
that's what I am doing but its returning an error saying that that object doesn't exist
 
D

Daniel O'Brien

Guest
Code:
    if(instance_exists(temporary_id)=false) {
       yGoal=y;
      xGoal=x+128;
      moving = true;
    }
you forgot the double equals in the if statement. I'm trying to figure out why this error is occurring. I don't really want to have to just work around it.
 

The-any-Key

Member
double equals
I am a old VB5 coder. We never double equals :)
We are lazy. We save 100,000 keystrokes by avoiding typing double = :)

One thing you could try is:
1# Export the project.
2# Open a new empty project.
3# Import the project.
4# Run. (this fix strange bugs in GMs project files)

Also make sure you dont have any "Undefined" instances in the room editor:
upload_2017-2-26_14-20-31.png
 
D

Daniel O'Brien

Guest
I am a old VB5 coder. We never double equals :)
We are lazy. We save 100,000 keystrokes by avoiding typing double = :)

One thing you could try is:
1# Export the project.
2# Open a new empty project.
3# Import the project.
4# Run. (this fix strange bugs in GMs project files)

Also make sure you dont have any "Undefined" instances in the room editor:
View attachment 7304
The issue has solved itself now. I turned off my computer and gave it a break then came back 20 mins later, ran the code and bam! it worked fine
 
Top