Windows Meteors Falling

I'm sure how to do this exactly. What I want to do is send some meteors downward and kill the player's characters.

This is the code:
GML:
timer_meteor_fall--;

meteor_timer--;

if (timer_meteor_fall <= 0)               //how often a meteor attack occurs
{
    
    //with (MeteorObjects)
    //{
    timer_meteor_fall = room_speed*15;
        
    //}
    if (meteor_timer <= 0)
    {
    
        instance_create_depth(0,y,-1200, MeteorObjects);
        instance_create_depth(300,y,-1200, MeteorObjects);
        instance_create_depth(600,y,-1200, MeteorObjects);
        instance_create_depth(900,y,-1200, MeteorObjects);
        instance_create_depth(1200,y,-1200, MeteorObjects);
        y++;
        
        
        
        if (y > 1000)
        {
            
        }
        meteor_timer = room_speed*15;
    }
    
}


        //locate sentry (bat) then kill him
        meteo = instance_place(x,y,SentryBatObject);
        if (meteo != noone)
        {
            instance_destroy(meteo)
        }
        instance_destroy(meteo)
        
        with (meteo)
        {
            instance_destroy()   
        }
The meteors fall correctly. It is the instance_place(x,y,SentryBatObject) that isn't working proprely. I plan on replacing SentryBatObject to SpecialBrains (a catch all)

I have just realized instance_place won't do with what I want to do. I want to destroy all of the bats that get hit by the MeteorObjects. It is sufficient to destroy all bats
In one swoop, like what I thought I was doing above. Would this work:
Code:
        //locate sentry (bat) then kill him
        
        meteo = instance_place(x,y,SpecialBrains);

        if (meteo != noone)

        {

            instance_destroy(meteo)

        }

        instance_destroy(meteo)

        

        with (meteo)

        {

            instance_destroy()   
        }
I'm lost.

-TWRaven
 

pipebkOT

Member
why not simply put collisions event on the bats and put the "instance_destroy()" there.
that way if something get a collision with a bat, the bat is detroyed.
 
GML:
timer_meteor_fall--;

meteor_timer--;

if (timer_meteor_fall <= 0)               //how often a meteor attack occurs
{
    
    //with (MeteorObjects)
    //{
    timer_meteor_fall = room_speed*15;
        
    //}
    if (meteor_timer <= 0)
    {
    
        instance_create_depth(0,y,-1200, MeteorObjects);
        instance_create_depth(300,y,-1200, MeteorObjects);
        instance_create_depth(600,y,-1200, MeteorObjects);
        instance_create_depth(900,y,-1200, MeteorObjects);
        instance_create_depth(1200,y,-1200, MeteorObjects);
        y++;
        
        
        
        if (y > 1000)
        {
            
        }
        meteor_timer = room_speed*15;
    }
    
}

        //locate sentry (bat) then kill him
meteo = instance_place(x,y,BatParentObject);
if (meteo != noone)
{
    instance_destroy(meteo)
}
@pipebkOT That's what I have so far. The meteors fall properly but don't do any damage.
 

Nidoking

Member
What object is the code you posted running in? Because that's what instance_place is checking against, not any MeteorObjects.
 

Nidoking

Member
No, I don't want the code for the step event. I'm asking why you are looking to see whether the LavaFireController is colliding with BatParentObject.
 

pipebkOT

Member
the collisions events and code should be in the meteor or bat objects, not on the controller.

and it should be as simple as putting
"instance_destroy(self)" in both objects collision events with eachother.
 
the collisions events and code should be in the meteor or bat objects, not on the controller.
Yeah I just changed that recently. Previously the instance_destroy was in meteors. Guess I didn't get it right the first time.

Does this sound right?

There is a collision between the Meteors and the Special Brains. On the collision between the two both calling instance_destroy
 

dialgpalkia

Member
The issue is that instance_place is checking for any instance of BatParentObject at the controller x and y. You want to use some sort of
with(BatParentObject){
if instance_place(x,y,MeteorObjects){
instance_destroy(self);
}
}
 
Ok. I'm trying to grasp this.

GML:
timer_meteor_fall--;

meteor_timer--;

if (timer_meteor_fall <= 0)               //how often a meteor attack occurs
{
    
    //with (MeteorObjects)
    //{
    timer_meteor_fall = room_speed*15;
        
    //}
    if (meteor_timer <= 0)
    {
    
        inst = instance_create_depth(0,y,-1200, MeteorObjects);
        inst2 = instance_create_depth(300,y,-1200, MeteorObjects);
        inst3 = instance_create_depth(600,y,-1200, MeteorObjects);
        inst4 = instance_create_depth(900,y,-1200, MeteorObjects);
        inst5 = instance_create_depth(1200,y,-1200, MeteorObjects);
        y++;
        
        with(BatParentObject)
        {
            if instance_place(x,y,MeteorObjects){
            {
                instance_destroy(self);
            }
    
        }
        /*
        if (y > 1000)
        {
            instance_destroy(inst)
            instance_destroy(inst2)
            instance_destroy(inst3)
            instance_destroy(inst4)
            instance_destroy(inst5)
        }
        */
        meteor_timer = room_speed;
    }   
}}

        //locate sentry (bat) then kill him
        meteo = instance_place(x,y,BatParentObject);
        if (meteo != noone)
        {
            instance_destroy(meteo)
        }
The meteors drop properly but there is no collision from what I can tell.
I corrected the BatParentObject to be BatParentObject. I also saved the
meteor objects in the int, int2, int3, etc. You'll see.
 

woods

Member
why not simply...

MeteorObjects
collision event with whatever the meteor is supposed to destroy:
instance_destroy(other)
instance_destroy(self)

profit ;o)
 

Nidoking

Member
You're still trying to find collisions between the LavaFireController and the BatParentObject. It's not going to work no matter how much other stuff you change. instance_place doesn't do what you seem to think it does.
 
You're still trying to find collisions between the LavaFireController and the BatParentObject. It's not going to work no matter how much other stuff you change. instance_place doesn't do what you seem to think it does.
Possiblyy. Maybe BatParentObject & LavaFireController don't have a sprite so you can't use instance_place. That's just a guess.
 
Last edited:

dialgpalkia

Member
So your code is basically setting "meteo" to whatever instance of BatParentObject is hitting the x and y of the LavaFireController object, not the meteor. instance_place(x,y,OBJ) gets the ID of any OBJ that collides with the object that calls the code's x and y position.

So to fix it, you have to redefine what exactly is colliding. Hence;
GML:
with(BatParentObject){
    if instance_place(x,y,MeteorObjects){ // "x" and "y" now become the x and y of BatParentObject, so if a meteor collides with any bat object,
        instance_destroy(self); // The bat object destroys itself.
    }
}
I think you're right about instance_place, so you'd need to find an alternative or as others have said set a "Collision with X" event and use instance_destroy()
 
Top