• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Issue with instances snapping to same position when exporting level.

RyanC

Member
Hi All,

I was wondering if anyone can see an issue with this code I am using?

My level editor in game has the following code to round and floor all x and y positions so that the level strings are shorter to send to the server etc.

The issue is that I am occasionally seeing objects over the top of each other after exporting the level.

After running some tests, it seems to happen when the instances are around the 0 position in the room.

GML:
global.X = floor(global.X);
global.Y = floor(global.Y);
                               
// new snap function
with(obj_place)
{
    x = global.X +(floor((x-global.X) / gem_width) * gem_width)+gem_width;                                              
    y = global.Y +(floor((y-global.Y) / gem_width) * gem_width)+gem_width;
}

repeat(instance_number(obj_place))
{
    with(instance_nearest(0,0,obj_place))
    {
        global.level_str += string(floor(x/gem_scale))+","
        global.level_str += string(floor(y/gem_scale))+","
        global.level_str += string(o_index)+","
        instance_destroy();
    }
}
 
Last edited:
Top