PRoblems with Snowball

Hi I have a line of code in my animation end
GML:
var currSpriteAnimName = sprite_get_name(sprite_index);
show_debug_message("Expecting Sprite Id: " + string(asset_get_index("SnowBatAttack")));
show_debug_message("Sprite Animation Ended: " + string(sprite_index) + ", " + currSpriteAnimName);


if (sprite_index == SnowBatAttack)
{

                    sprite_index = SnowBatAttack;       
                    show_debug_message("Animation End. Creating snowball");
                    spit_inst = instance_create_depth(x+60, y+60, -12000, Snowball);
                    
                    spit_inst.source_x = x-20;
                    spit_inst.source_y = y-20;
                    
                    spit_inst.t_x = t_x;
                    spit_inst.t_y = t_y;
                    
                    sprite_index = SnowBatStill
    
}




if (sprite_index == FrankensteinMonsterSendOutBrains)
{
    sprite_index = FrankMonsterIdle;
}
spit_inst = instance_create_depth(x+60, y+60, -12000, Snowball);

This is the error mesage:

Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Other Event: Animation End
for object SnowBatObject:

Creating instance for non-existing object: 623
 at gml_Object_SnowBatObject_Other_7 (line 12) -                                    spit_inst = instance_create_depth(x+60, y+60, -12000, Snowball);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_SnowBatObject_Other_7 (line 12)
I declared spit_inst in the create event but it still gives that error?
 

Mk.2

Member
Apparently you don't have an object called Snowball in your object directory. Perhaps a typo when you named the object?
 

TsukaYuriko

☄️
Forum Staff
Moderator
The error message does not have anything to do with spit_inst; not sure what makes you think so. It says "Creating instance for non-existing object: 623", where 623 is the value of Snowball. Is this an actual object defined in the resource tree? Because the error message says it isn't.
 
Tsuka: Yes it does.

GML:
spit_inst = instance_create_depth(x+60, y+60, -12000, Snowball);
Code:
Creating instance for non-existing object: 623
 at gml_Object_SnowBatObject_Other_7 (line 12) -                                    spit_inst = instance_create_depth(x+60, y+60, -12000, Snowball);
 

Mk.2

Member
It's telling you there's an error at that line, not that there's an error related to spit_inst. It's also telling you that the error is that you're referencing an object which doesn't exist in your project, and the only reference to an object in that line is "Snowball". Do you have an object called "Snowball" with the exact same spelling, and upercase/lowercase letters in your resource tree?
 
This sound very similar to the last time you had an issue with creating an instance, and in that last time you were not passing in the object resource but a sprite resource:
However, as everyone else is saying, it is likely that this time around you do not have an object resource id that happens to coincide with the sprite resource id.
Make sure that what you are passing into instance_create_depth is in fact an object and that it does exist in your resource tree with exactly the same name as you have typed it in your code.
 
Here's a tip: there are default colour codes dedicated to resources and functions and the like. If you input an object name and the text still remains blue instead of changing to red, the name is incorrect and you're using what will most likely be an undefined variable.
 
Top