Issue with "TypeError Cannot read property 'width' of undefined", please help!

thomasm

Warper
Member
Joined
Jul 24, 2021
Messages
3
Reaction score
1
First Language
Dutch
Primarily Uses
RMMZ
Hi there,

I've been working on a game, using RPG Maker MZ, for some time now, but I'm encountering a problem I can't seem to fix. I've been going through the forums, without any luck. This is my first time posting a question online, and I hope someone can help me! I have no real coding experience...

So, about the error: There are a lot of random encounters in the game, and sometimes with a random encouter, I suddenly get the error "TypeError Cannot read property 'width' of undefined". I exchanged the images, no luck. I switched off my plugins (SRD and CGMZ), no luck. All my enemies and troops are consistent and don't refer to any deleted images or anything.

I switched on DevTools, and this is the error-message I got. I hope someone can help me understand this! If I'm posting this wrong/in the wrong place, please let me know!

rmmz_managers.js:2030 TypeError: Cannot read property 'width' of undefined
at Sprite_Enemy.updateFrame (rmmz_sprites.js:1003)
at Sprite_Enemy.Sprite_Battler.updateMain (rmmz_sprites.js:504)
at Sprite_Enemy.Sprite_Battler.update (rmmz_sprites.js:485)
at Sprite_Enemy.update (rmmz_sprites.js:961)
at Sprite.update (rmmz_core.js:1971)
at Sprite.update (rmmz_core.js:1971)
at Spriteset_Battle.Sprite.update (rmmz_core.js:1971)
at Spriteset_Battle.Spriteset_Base.update (rmmz_sprites.js:3162)
at Spriteset_Battle.update (rmmz_sprites.js:3627)
at Scene_Battle.Scene_Base.updateChildren (rmmz_scenes.js:129)
SceneManager.catchNormalError @ rmmz_managers.js:2030
SceneManager.catchException @ rmmz_managers.js:2018
SceneManager.update @ rmmz_managers.js:1941
Graphics._onTick @ rmmz_core.js:800
TickerListener.emit @ pixi.js:9474
Ticker.update @ pixi.js:9928
Ticker._tick @ pixi.js:9679
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
requestAnimationFrame (async)
Ticker._tick @ pixi.js:9682
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,771
Reaction score
2,123
First Language
EN
Primarily Uses
RMMZ
It implies that one or more enemies involved do not have an image at the point when the error occurs. Ideas:
  1. Check your enemies! Make sure all enemies have an image assigned. I guess you've already checked, but it's best to make sure. :kaohi:

  2. Check your troops! Maybe some of them have enemies without images. If you test a troop and the error occurs, press the Clear button to remove all enemies then re-add the enemies that should be there.

  3. Check your plugins! After making any changes in the Plugin Manager, save your project. If you don't save before testing, those changes will not be seen during test.
Also, note that you can update your project's core scripts to a newer/older version via Game > Update Corescript from the editor's menu bar. Newer versions have various bug-fixes, details here:
I'm mentioning this because your error message reports line number 1003 but I think that would be 1004 in v1.3.2 of the core scripts. :kaoswt:
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,724
Reaction score
8,508
First Language
German
Primarily Uses
RMMV
basically the key part of the error message is the "of undefined".
that always means that the engine is missing a data object, either because you deleted the object in the database without removing it everywhere it was used, or because of a plugin data conflict.

In this specific case I agree that it is most likely a missing enemy since you already replaced the images of all enemies you believe to be used - which rarely include forgotten and invisible references to deleted enemies.
 

thomasm

Warper
Member
Joined
Jul 24, 2021
Messages
3
Reaction score
1
First Language
Dutch
Primarily Uses
RMMZ
Wow, thanks a bunch, caethyril for your detailed and helpful answer!
Finally the issue seems to have been resolved...I reset all the plugins again, which didn't seem to work, but then I replaced one of the enemy-images I created with a new version version (just saved the .png again, no modifications, but gave it a different name), and that seems to have done the trick somehow...

I also updated the corescript, thanks for pointing that out!

Thank you very much!!! This was a great first experience of asking a question here ^.^

It implies that one or more enemies involved do not have an image at the point when the error occurs. Ideas:
  1. Check your enemies! Make sure all enemies have an image assigned. I guess you've already checked, but it's best to make sure. :kaohi:

  2. Check your troops! Maybe some of them have enemies without images. If you test a troop and the error occurs, press the Clear button to remove all enemies then re-add the enemies that should be there.

  3. Check your plugins! After making any changes in the Plugin Manager, save your project. If you don't save before testing, those changes will not be seen during test.
Also, note that you can update your project's core scripts to a newer/older version via Game > Update Corescript from the editor's menu bar. Newer versions have various bug-fixes, details here:
I'm mentioning this because your error message reports line number 1003 but I think that would be 1004 in v1.3.2 of the core scripts. :kaoswt:
 

thomasm

Warper
Member
Joined
Jul 24, 2021
Messages
3
Reaction score
1
First Language
Dutch
Primarily Uses
RMMZ
basically the key part of the error message is the "of undefined".
that always means that the engine is missing a data object, either because you deleted the object in the database without removing it everywhere it was used, or because of a plugin data conflict.

In this specific case I agree that it is most likely a missing enemy since you already replaced the images of all enemies you believe to be used - which rarely include forgotten and invisible references to deleted enemies.
Thanks, Andar! Indeed it seemed to be connected to the enemy images!
 

Latest Threads

Latest Profile Posts

Working on a characteeer! (Why is it so hard to color hair?) ;-;
Silly-Sketches.png
Just finished eventing a couple simple puzzles in RMMV, for my very first game "Sample Quest." Just messing around, throwing things together, and calling it a story XD On a non-RM note, got my hair cut today!
I feel the need to inform everyone on the forums NOT to go with Web Hosting Canada for your hosting needs. It is by far the worst customer service and just overall experience I have ever had with hosting and I am Canadian...
BCj
Got another eye surgery monday. Hope I'll recover quick and all's well. A bit tired of surgeries. On a happy note, working on the next chapter of Escalia so hope I can continue soon :)
Celebrating the arrival of autumn in the Northern Hemisphere :)

Forum statistics

Threads
115,368
Messages
1,089,316
Members
150,057
Latest member
kotfwing
Top