Error saving game state when platforms are around

0 favourites
  • 9 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • Sometimes, when I try to use the built in Save function (for checkpoints to load on death), I get the following error:

    Uncaught (in promise) TypeError: this._wasOverJumpthru.GetUID is not a function at PlatformInstance.SaveToJson (runtime.js:9:507) at BehaviorInstance.SaveToJson (behaviorInstance.js:4:172) at Instance.SaveToJson (instance.js:28:407) at objectClass.js:30:45 at Array.map (<anonymous>) at ObjectClass._SaveToJson (objectClass.js:30:30) at C3Runtime._SaveToJsonString (runtime.js:105:420) at C3Runtime._DoSaveToSlot (runtime.js:102:335) at C3Runtime._HandleSaveOrLoad (runtime.js:100:143) at C3Runtime.Tick (runtime.js:76:186)

    Has anyone ever seen this before? This only happens on 2 specific (and large) layouts with a lot of objects using the Jumpthru behavior.

    Case 1: Sometimes when you load the level, some of my Jumpthru objects get despawned immediately (the level changes over the course of the story). The game saves when the player performs a specific action.

    Case 2: The game tries to save 0.1s after the layout starts (to give dynamically-created objects time to spawn). No Jumpthru objects are despawned by this point.

    Take note that the player object (with the Platform behavior) is dynamically created at the start of the layout, as there are multiple players to choose from. Could this be related?

    EDIT: Deleting every Jumpthru object from the layout ahead of time makes the bug go away, so they are definitely the culprit here. I just don't know how to fix this without drastically altering my level design to work without them.

    EDIT 2: Statically placing the player object (instead of spawning it dynamically) does not help.

  • If you can reliably reproduce this error in a small demo project, you need to submit a bug report.

    Are these platforms dynamically spawned in runtime? If they are static, you can add NoSave behavior to them.

    One workaround that comes to mind is to use temporary placeholder sprites in place of those platforms. Spawn the placeholders, save the game, then replace the placeholders with real platforms. And on loading the game - replace them with real platforms.

  • Thanks, swapping the JumpThrus with dummy objects seemed to fix the problem.

    I would definitely submit a bug report if I thought I could reproduce this reliably, but it just started happening out of the blue and I can't think of anything these 2 test cases have in common.

  • UPDATE: This error has cropped up again. This time, even if I don't have a reproducible case, I DO have a stacktrace and I examined the value to see why the error is happening:

    this is an object with the Platform behavior. While the instance is being saved as JSON when I save the game state,

    this._wasOverJumpthru.GetUID() fails because this._wasOverJumpthru === true. Somewhere in the Construct 3 code, this property is being set to a boolean value when it's supposed to be an object.

    Is this enough to help track down the cause of the bug, in combination with the stacktrace in my first post?

    EDIT:

    I tracked down the offending code in the minified runtime.js:

    this._wasOverJumpthru=!!this._runtime.GetCollisionEngine().TestOverlapJumpthru(this._inst)

    It looks like this code is incorrectly setting the variable to a boolean when it's supposed to be an object or null. When I call that method without the "!!", it correctly returns an IInstance with a Jumpthru behavior.

  • You should definitely report your findings:

    github.com/Scirra/Construct-3-bugs/issues

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, shortly after making that last reply I came to the same conclusion and filed a bug here: github.com/Scirra/Construct-3-bugs/issues/6187

    Ashley has taken a look at it and says it should be fixed by the next beta release.

  • MoscowModder Sorry to hijack your thread, but I didn't see a way to PM you and I wanted to ask you about an old post of yours. Did you ever figure out a good solution to changing sprite animations during timelines? I'm looking to do the same thing -- have sprite animations change during a timeline -- and I'm actually pretty surprised it's not a standard option.

    Thanks

  • pandabear7413 As a matter of fact I did, but it's not pretty.

    First, I put in keyframes named "Animation|objectName|myAnimationName"

    I have an event with the conditions:

    • On any keyframe reached
    • find(Timeline.KeyframeTags, "Animation") >= 0

    In the actions for this, I have the following JavaScript snippet. This parses the object name and animation name out of the keyframe, finds the object, and applies the animation. Note that "localVars.keyframes" is a variable I saved the value of "Timeline.KeyframeTags" to.

    const tags = localVars.keyframes.split(" ");
    console.log(tags);
    
    tags.forEach(tag => {
    	const args = tag.split("|");
    	
    	if(args[0] == "Animation") {
    		// Change an object's animation
    		// Animation|{ObjectName}|{AnimationName}
    		const obj = runtime.objects[args[1]].getFirstPickedInstance();
    		obj.setAnimation(args[2]);
    		obj.isVisible = true;
    	}
    });
    

    This isn't very flexible so you may need to refine it for your own purposes.

  • Very clever, thank You! This is in by backlog but looking forward to giving it a try.

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