Download

Game-crashing error when I try to destroy certain actors

My pawns have some equipment they’re wearing. I’m not using the built-in inventory classes. In the pawns’ Destroyed() event, I destroy their equipment. 100% of the time, that causes this game-crashing error:


Critical: appError called: Cast of Package HimekoSutoriContentNew.Weapons to Level failed
Critical: Windows GetLastError: Incorrect function. (1)
Log: === Critical error: ===
Cast of Package HimekoSutoriContentNew.Weapons to Level failed

I’ve never seen that error before. Do you think it has anything to do with upgrading to Windows 10?

I only get that error when I try destroying the equipment. If I leave the dead pawns’ equipment floating in the void, then the game plays out just fine.

I’m not doing anything strange in the Destroyed() event:



simulated event Destroyed()
{
...
	if(BodySlotItem != none)
	{
		BodySlotItem.Destroy();
		BodySlotItem = none;
	}
	if(MainHandItem != none)
	{
		MainHandItem.Destroy();
		MainHandItem = none;
	}
	if(OffHandItem != none)
	{
		OffHandItem.Destroy();
		OffHandItem = none;
	}
	if(AccessoryItem != none)
	{
		AccessoryItem.Destroy();
		AccessoryItem = none;
	}
	super.Destroyed();
}

The “…” is where I deleted non-problematic code.

The equipment classes have


	bStatic=false
	bNoDelete=false

in their default properties.

Any idea why I can’t destroy my equipment?

If this helps, I create some characters by dropping pawns into the game world, setting their stats, saving them as archetypes, and then spawning them at runtime in Kismet. I create equipment by dropping the placeable equipment classes into the game world, setting the stats, and saving those as archetypes. But I give the equipment to the pawns by editing their archetypes, and setting the equipment vars to the equipment archetypes in the content browser. Is that problematic? Do I need to spawn the equipment in-game, and then assign it to the pawns? That could take a long time to redo…

If its a hassle to recode then why not teleport the inventory out of the way instead of destroying …

Yeah, it was because I was trying to destroy archetypes, and the pawns never got their own instances of equipment.

I guess that here there was no real reason why I had to destroy the equipment here. If it was just an archetype, and I wasn’t making instances of it, then it’s not like there was more memory being used or anything, right? But there would have been a bunch of problems that I would run into in the future with everyone actually using an archetype, so I decided to recode a bunch of things. It ended up not being so bad, and it’ll be much better in the long run for each pawn to have its own instance of the equipment. With instanced equipment, I can do equipment upgrades and customization, for example.