This is a weird one. So I've got a Necromancer NPC that casts a Touch reanimation spell on an NPC that's dead by default (health at zero in the editor). It took a while to get just that working properly (the game doesn't seem to like reanimating dead-by-default actors), but now it does. The new problem is that, after the reanimation takes place, if I reload a save prior to the reanimation, things get... weird.
On that first reload, the dead NPC's model is properly placed and positioned (as it was in the Havok sim). But somehow in reloading the model got decoupled from the actual actor, which is now invisible, standing behind their own corpse. Yeah. After subsequent reloads, the same thing occurs, with the invisible actor behind their starting position, but the model of the body is drawn somewhere else, nearby. The body is positioned in the same way (animation-wise, not coordinate-wise), but might be on the floor ten feet away, or floating in the air beneath the room's ceiling, or sticking out of a wall.
Here's the code attached to the dead NPC to be reanimated. The Necromancer's own script activates the dead NPC before casting the Reanimation spell. I've tried calling Reset3DState all three blocks, just to be sure, but that's probably just affecting the animation position, not the weird decoupling. I'm considering using a MoveTo on Activate, before the reanimation, but again I'm not sure if that'll stop the decoupling effect.
ScriptName ESRenaSulScript
short doOnce
ref mySelf
Begin OnLoad
set mySelf to getSelf
End
Begin OnActivate
if ( doOnce == 0 )
mySelf.setav health 0 ;to reset Health change during previous loads
reset3DState
mySelf.setav health 100 ;Used to fix AI issues with reanimating an actor with 0 base health
set doOnce to 1
else
Activate
endif
End
Begin OnReset
mySelf.setav health 0
reset3DState
set doOnce to 0
End
EDIT: Woah, how do I make the code segment not look terrible and unreadable?