• 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!

[SOLVED]Check instance collision

C

Carpe Zythum

Guest
Is there a way to test collision before creating an instance?
( I want to spawn my weed object only if there isn't one there )
This code doesn't work though:
Code:
/// Spawn grass
if(global.game_time_status = TIMEOFDAY.DAY) {
    alarm[1] = spawn_grass_time;
    var xx = random_range(32, room_width - 32);
    if(place_empty(xx,480)) {
        instance_create(xx,480,obj_weed); // Create the new grass on the ground at the random position
    }
}
EDIT: This code is being called in the obj_spawn object.
 
Last edited by a moderator:
C

Carpe Zythum

Guest
I've solved it. This was an important part of the documentation I disregarded: running the code must have a valid collision mask
The problem was, my calling object didn't have a sprite ( since it was a system object ). Adding a collision mask to the object solved this issue.
 
Top