Error: cat is not defined on line 2 in script "update"?

I don’t know how to describe it, it’s as if the object names got undefined or something. I tried switching between “cat.mousex” and “this.mousex” to no avail, I have no idea what’s happening and how to fix it. I’m using the latest version, 1.19.3

I… apologise for the music.

console

ReferenceError: cat is not defined at Wick.Clip.eval (eval at _evalScript (https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:56140:12), :4:1) at Wick.Frame._runFunction (https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:56203:25) at https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:55979:27 at Array.forEach () at Wick.Frame.runScript (https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:55977:28) at https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:51437:48 at Array.forEach () at https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:51425:28 at Array.forEach () at Wick.Project.runScheduledScripts (https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:51424:35)

Error: cat is not defined on line 2 in script “update”. at onError (https://www.wickeditor.com/editor/static/js/main.88ccc610.chunk.js:1:764986) at Wick.Project.stop (https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:51562:47) at https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:51486:14

Error: cat is not defined on line 2 in script “update”. at onError (https://www.wickeditor.com/editor/static/js/main.88ccc610.chunk.js:1:764986) at Wick.Project.stop (https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js:51562:47) at t.e.componentDidUpdate (https://www.wickeditor.com/editor/static/js/main.88ccc610.chunk.js:1:765274) at ls (https://www.wickeditor.com/editor/static/js/1.869244a2.chunk.js:1:1149800) at https://www.wickeditor.com/editor/static/js/1.869244a2.chunk.js:1:1167806 at t.unstable_runWithPriority (https://www.wickeditor.com/editor/static/js/1.869244a2.chunk.js:1:1187080) at Ui (https://www.wickeditor.com/editor/static/js/1.869244a2.chunk.js:1:1111120) at El (https://www.wickeditor.com/editor/static/js/1.869244a2.chunk.js:1:1164296) at cl (https://www.wickeditor.com/editor/static/js/1.869244a2.chunk.js:1:1160420) at https://www.wickeditor.com/editor/static/js/1.869244a2.chunk.js:1:1111410

DAD.wick (88.5 KB)

Welcome back, thomas!

I probably don’t know what it’s doing, but the update event seems to be the reason for it.

the default script will run each time the frame is entered, so with that in mind:
this code that you wrote in the default script will run as many as the amount of times you entered it:

//inside default script
onEvent('update', function () {
if (cat.hits(dog)) {
 gotoAndStop(3);
}});

it was checking TWICE if the cat is colliding with the dog.

and because we moved to another frame, I assumed it was unable to find the cat object, thus crashing.

just remove the event code and write in the update script instead of using the event, then it should work as usual.

Ah also place this in the cat’s default script:

this.x = 382.457;
this.y = 292.677;

because if you don’t, the cat will stay in the same place before we left the frame and will continually collide with the dog:

yeah…

1 Like

oops i forgot about the update script lol. it works now, thank you! :D

1 Like