1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 [Solved] Unknown error after importing project from GM8.1 to GM:S 1.4

Discussion in 'Programming' started by Zachary_Alan, Jul 31, 2019.

  1. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    Hello, I started getting errors in my pedestrian object after importing my game from GM 8.1 to GM:S 1.4. I don't get what this error is saying at all or what's causing it, I didn't make any changes other than adding physics to the car object.
    ___________________________________________
    ##########################################################################################
    FATAL ERROR in
    action number 2
    of Step Event0
    for object obj_ped:

    Unable to find any instance for object index '103985'
    at gml_Object_obj_ped_StepNormalEvent_2 (line 10) - if(state == 0 and instance_exists(myGuide)){
    ##########################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Object_obj_ped_StepNormalEvent_2 (line 10)

    Here's the code in the script object if it would help

    Code:
    ///AI Core - state 0: walking
    
    ///Health
    if(Health <= 0){
        state = 2;
    }
    
    if(state == 0 and instance_exists(myGuide)){
        
        injured = false;
    
        ///Walk towards guide
        if(walk == true){
            mp_potential_step( myGuide.x , myGuide.y , walkSpeed , false );
        }
        
        ///Stop if close to guide
        if(distance_to_object(myGuide) < 5 and !state == 2){
            walk = false;
        }else{
            walk = true;
        }
        
        ///Run over
        if(instance_exists(obj_car)){
            nearestCar = instance_nearest( x , y , obj_car)
            if(instance_exists(nearestCar)){
                nearestCar = instance_nearest( x , y , obj_car);
                    if(collision_circle( x , y , 20 , obj_car , true , true )){
                        if(nearestCar.speed > 1 and collision_circle( x , y , 5 , obj_car , true , true )){
                            state = 2;
                        }
                    }
                }
        }
    
        ///Bullet collision   
        if(collision_circle( x , y , 10 , obj_bullet , false , false )){
            if(global.blood == true){
                instance_create( x , y , obj_bloodHit);
            }
            Health -= obj_player.bulletDamage;
        }
            
        
    }
     
  2. Tthecreator

    Tthecreator Your Creator!

    Joined:
    Jun 20, 2016
    Posts:
    757
    What exactly is myGuide? Is it a variable or an object?
     
  3. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    It's the instance id of an object. It doesn't destroy itself unless the ped object doesn't exist in case you're thinking the guide is being destroyed
     
  4. Tthecreator

    Tthecreator Your Creator!

    Joined:
    Jun 20, 2016
    Posts:
    757
    It's just that 103985 is a very weird number for an instance id or an object index. Can you get the "id" and the "object_index" of the myGuide object for me?
     
  5. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    I set it up to display the instance id, and it's different every time...
     
  6. Tthecreator

    Tthecreator Your Creator!

    Joined:
    Jun 20, 2016
    Posts:
    757
    The thing about instance_exists is that you can give it two values.
    I'll quote the manual:
    "This function can be used in two ways depending on what you wish to check. You can give it an object_index to check for, in which case this function will return true if any active instances of the specified object exist in the current room, or you can also supply it with an instance id, in which case this function will return true if that specific instance exists and is active in the current room."

    The error message means that GM thinks you are supplying the instance_exists function an object_index. However, the object_index 103985 doesn't exist (or at least that is my guess).
     
  7. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    What I don't get is why it worked in GM8 but not GMS. I thought checking if an instance exists was the same in both. Also, the guide is never meant to despawn unless the ped despawns
     
  8. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    2,004
    Have your instance either display its ID on screen or debug message it to output during creation. You can then compare it to what the error message throws out and confirm if your variable is holding the correct value. I agree what seems to be happening here is: instance_exists first tries to find an instance holding the ID value set into myGuide variable, but fails to find any. It then assumes you must be referring to an object instead. But there is no object with that ID either, so it throws an error. Your instance might as well exist, but your check is receiving wrong value(s). If there's only one instance of that object ever, you could check through the object ID instead of using instance ID saved to a variable.
     
  9. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    Thanks, but what is an object ID? Is it just the name of the object? I'm just now noticing that both the car guides and ped guides are acting weird. Is there a reason why it's ****ing up in GMS when it worked fine in GM8? I know they are different engines but I thought the basics of GML would be the same.
     
  10. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,122
    The object ID is the object_index. It's not the name of the object -- that's just an enumerator for the object_index. But what NightFrost is saying is if your game will only have one pedestrian guide and only one vehicle guide active at any time, then you could just use if instance_exists(oPed_Guide) or whatever your guide is called.

    Since this is GM1.4 we're dealing with here, go into the Global Game Settings and turn on Short-Circuit Evaluation.

    What's the code you have that sets myGuide? Where is that code called?

    103985 is not an odd instance ID at all, it's a typical id to be expected if 3985 instances have been created since the start of the game.

    Does the error come up immediately? Or does it come up after you've done something in the game?

    Do you mean "physics" as just a lazy term for movement code you wrote from scratch, or do you mean you are using the built-in Physics engine? If you are using the engine, then you need to enable the room to use Physics. And if you've enabled the room to use Physics, certain variables stop behaving correctly, making it doubly important to see how you assigned myGuide.
     
  11. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    Thanks for replying, I just ran the game without Short-Circuit Evaluation for fun, but the issue seems to be fixed. I don't know what it even is, maybe whatever it does doesn't happen in GM 8.1? I tried to look it up but I couldn't find a straight answer.
     
  12. Bart

    Bart Member

    Joined:
    Jun 21, 2016
    Posts:
    193
    Your issue isn't properly fixed yet.

    If you don't get the error anymore with short-circuit evaluation turned on it just means you never end up in a situation where state == 0.
    Because of the short-circuit evaluation the instance_exists(myGuide) check is never executed.

    By the look of it, it seems that GM seems to consider 103985 to be an object index, while every value > 100000 is supposed to be an instance id.
    Did you place myGuide in the room via the Room Editor or did you create it in code?
    If it's the former you could try to remove it from the room and adding it back again (make sure it's created at the right time).
    If it's the latter the best thing to do is to add some debug code and see what comes out, as mentioned in the previous posts.
     
  13. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    It fixed itself when I turned short circuit evaluation off.
     
  14. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,122
    What he means is something is going on when your state is 0, or rather when state is not 0. The value of state for some reason has a direct correlation to the value and/or existence of myGuide. Toggling short-circuit evaluations just tells GM to ignote half of that conditional. Consider the following:
    Code:
    if A and B { C; }
    if A or B { D; }
    if A xor B { E; }
    
    Now, in GM8, conditions A and B would both be checked 3 times. But with short-circuit evaluations, only A would be checked 3 times, whereas B only needs to be checked once, thus potentially speeding up the code slightly. Let's look at each line and see how short-circuit evaluations may or may not help it.

    if A and B { C; }
    At what point will C be performed? When A and B are both true, and only when A and B are both true. So if A is true, we need to check the value of B. What if A is false? In GM8, that doesn't matter -- we still need to check the value of B. This is just a waste of the CPU's time, especially if either A or B are complex conditionals which take a lot of time to calculate. So with short-circuit evaluations, if A is false, B never gets checked. This means given a completely random distribution of A and B, we only need to check B 50% of the time. We can lower this % even more, but more on that later.

    if A or B { D; }
    At what point will D be performed? When either A or B are true, even if both are true. So if A is false, we still need to check the value of B. Again, given a completely random distribution of A and B, we only need to check B 50% of the time with short-circuit evaluations.

    if A xor B { E; }
    At what point will E be performed? When either only A or only B is true. Short-circuit evaluations don't help us here, as both conditions must be checked every time. If A is true, then we need to check if B is false. If A is false, then we need to check if B is true. This is why I said B would need to be run at least once in the code above.

    You could do your own derivation of short-circuit evaluations in GM8, but it's more lines of code People tend to like slower, shorter code over faster, verbose code when the gains are so miniscule.
    Code:
    if A
       if B
          C;
    
    if !A {
       if B
          D;
    }
    else
       D;
    
    if A xor B
       E;
     
  15. Zachary_Alan

    Zachary_Alan Member

    Joined:
    Dec 1, 2018
    Posts:
    38
    I get it now, thanks! But I just found out it just takes longer for the error to occur or makes it less likely to happen without short circuit evaluation than with it. I'm fiddling around with the code but every time I fix something, something else starts causing trouble.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice