Why in the code below, do I get entity does not exist after deleting an emitter. The emiiter is deleted because its parent is removed, I get the error at these lines below.
TurnEntity e\pivot, e\turnx#,e\turny#,e\turnz#
MoveEntity e\pivot,0,0,e\movespeed#
It should not try to move that e\pivot after its been
deleted. I removed that instance of e.emitter.
[\CODE]
Function handleemitters()
For e.emitter= Each emitter
FLAGD=False
If e\active Then
;decide if its time to spawn a dirt
If e\spawntimer#<(gametimer#) And dirtcount=<maxdirt Then
e\spawntimer#=(e\spawnrate#+gametimer#)
Dirtcount=dirtcount+1
;spawn dirt
d.dirt=New dirt
d\sprite=CopyEntity (e\hiddensprite)
ShowEntity d\sprite
d\xv#=e\xv#
d\yv#=e\yv#
d\zv#=e\zv#
PositionEntity d\sprite,EntityX(e\pivot,1)+Rnd(-e\area#,e\area#),EntityY(e\pivot,1)+Rnd(-e\area#,e\area#),EntityZ(e\pivot,1)+Rnd(-e\area#,e\area#)
d\forces=e\forces
d\rotationinc#=e\rot#
d\alpha#=e\alpha#
d\decay#=e\decay#
d\scalechange#=e\scalechange#
d\mass#=e\mass#
d\scale#=e\startscale#
d\lifespan#=e\plifespan#
d\lifetimer#=(gametimer#+d\lifespan#)
EndIf
;do turns movements on emitter
;if parented.. follow parent
TurnEntity e\pivot, e\turnx#,e\turny#,e\turnz#
MoveEntity e\pivot,0,0,e\movespeed#
;see if emitter has lifespan if so check to see if it has expired
EndIf ;IF ACTIVE
If e\lifetime#<>0 Then
If e\lifetime#<gametimer# Then
flagd=True
EndIf
EndIf
If e\parent Then
If GetParent(e\pivot)=0 Then
flagd=True
EndIf
EndIf
If flagd=True Then
FreeEntity e\HIDDENSPRITE
FreeEntity e\pivot
Delete e
EndIf
Next
End Function
[CODE\]
TurnEntity e\pivot, e\turnx#,e\turny#,e\turnz#
MoveEntity e\pivot,0,0,e\movespeed#
It should not try to move that e\pivot after its been
deleted. I removed that instance of e.emitter.
[\CODE]
Function handleemitters()
For e.emitter= Each emitter
FLAGD=False
If e\active Then
;decide if its time to spawn a dirt
If e\spawntimer#<(gametimer#) And dirtcount=<maxdirt Then
e\spawntimer#=(e\spawnrate#+gametimer#)
Dirtcount=dirtcount+1
;spawn dirt
d.dirt=New dirt
d\sprite=CopyEntity (e\hiddensprite)
ShowEntity d\sprite
d\xv#=e\xv#
d\yv#=e\yv#
d\zv#=e\zv#
PositionEntity d\sprite,EntityX(e\pivot,1)+Rnd(-e\area#,e\area#),EntityY(e\pivot,1)+Rnd(-e\area#,e\area#),EntityZ(e\pivot,1)+Rnd(-e\area#,e\area#)
d\forces=e\forces
d\rotationinc#=e\rot#
d\alpha#=e\alpha#
d\decay#=e\decay#
d\scalechange#=e\scalechange#
d\mass#=e\mass#
d\scale#=e\startscale#
d\lifespan#=e\plifespan#
d\lifetimer#=(gametimer#+d\lifespan#)
EndIf
;do turns movements on emitter
;if parented.. follow parent
TurnEntity e\pivot, e\turnx#,e\turny#,e\turnz#
MoveEntity e\pivot,0,0,e\movespeed#
;see if emitter has lifespan if so check to see if it has expired
EndIf ;IF ACTIVE
If e\lifetime#<>0 Then
If e\lifetime#<gametimer# Then
flagd=True
EndIf
EndIf
If e\parent Then
If GetParent(e\pivot)=0 Then
flagd=True
EndIf
EndIf
If flagd=True Then
FreeEntity e\HIDDENSPRITE
FreeEntity e\pivot
Delete e
EndIf
Next
End Function
[CODE\]