Error on save & load function. Bug?

0 favourites
  • 7 posts
From the Asset Store
7 Errors
$15 USD
7 Errors is a game where you have to find the 7 mistakes before time runs out. Can you find all 7? Have fun looking.
  • Hey there! So i am trying to add a save and load function, but i keep getting the same error no matter what.

    I do not use any plugins or anything like that.

    Error says;

    Javascript error!

    Uncaught TypeError: Cannot read property 'ApplyLinearImpulse' of null

    http://localhost50000/Physics_Behaviour.js, line 2223 (col12)

    This may be a bug in Construct 2 or a third party plugin or behaviour -

    please report it to the developer following the bug report guidelines.

    EDIT; It happens always when the player is in a different layout than the layout the game was saved in.

  • We will definitely need your project .capx or at least a shortened version of it to reproduce the possible bug and to help you with this.

    I am positive though that it is no bug and just a line of code that needs to be changed.

  • We will definitely need your project .capx or at least a shortened version of it to reproduce the possible bug and to help you with this.

    I am positive though that it is no bug and just a line of code that needs to be changed.

    Unfortunately i can not give u any type of version of this as the scale is way too large and the game almost done.

    Is there no other way to find out what the problem is?

  • Seems to be working now when i deleted the physics impulse.

    Code is;

    'X on created, - apply physics impulse 10 at angle 270 + (15-random30)) at image point 0'

    Why would this crash the game? And how to fix this code?

  • Cannot read property 'ApplyLinearImpulse' of null

    Judging from this, it sounds like the action is trying to apply an Impulse on an object that doesn't exist.

    Since you said that the error occurs when you are in a different layout than the one the game saved before:

    • Can the object that you are applying the impulse to be destroyed?
    • What kind of object is it that you are applying the impulse to?
    • What physics type are you using? Did you try to change it? (Project properties -> asm.js/web

    Can you also try to put a "Wait dt seconds" before you apply the impulse?

    If all this doesn't help, you can try to save the object's status' in an Array and save the Array as JSON in LocalStorage.

    This will, of course, be a very tedious thing to do, but if it's the last option, you might wanna do this instead of leaving the error in your game.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > Cannot read property 'ApplyLinearImpulse' of null

    >

    Judging from this, it sounds like the action is trying to apply an Impulse on an object that doesn't exist.

    Since you said that the error occurs when you are in a different layout than the one the game saved before:

    • Can the object that you are applying the impulse to be destroyed?
    • What kind of object is it that you are applying the impulse to?
    • What physics type are you using? Did you try to change it? (Project properties -> asm.js/web

    Can you also try to put a "Wait dt seconds" before you apply the impulse?

    If all this doesn't help, you can try to save the object's status' in an Array and save the Array as JSON in LocalStorage.

    This will, of course, be a very tedious thing to do, but if it's the last option, you might wanna do this instead of leaving the error in your game.

    Hey there! Thanks for ur time, appreciated! Adding DT worked and the problem is solved.

    The impulse was on a ''floating'' text message with a destroy on fade. No idea what caused the error. I tried changing physics but it did not help.

    However adding a DT time worked, same goes for ''wait 0.1 second''.

    Thank you for your kind reply ^_^

    -All the best!

  • You could also use Wait 0 seconds, should have the same result.

    If you're interested in the reason why this action might be needed in some cases:

    When an object is created, it sometimes needs a frame to "prepare itself".

    During that time, you can set e.g. parameters or coordinates, but the object isn't interactive yet, thus can't be affected by other plugins/behaviors.

    To give an example, the Text object expression Text.TextHeight doesn't return the correct height in the same frame as setting the text.

    This means, when you change the text and put an action underneath that, calling the .TextHeight expression, it will not return the correct number.

    But if you put a Wait dt seconds in between, it will work.

    So, if you have an issue like this again, where an object just doesn't seem to react or an object expression doesn't return what it should, you might wanna wait a frame.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)