Topic: Removing Scene Nodes from an Array.
I need to create scenenodes in an array, find information about each element, then delete certain scenenodes within the array.
I wrote this code to delete certain nodes but after I delete some nodes then run the function again I receive an error saying "unhandled memory exception, cannot getposition()"
'Delete Asteroid
Local PlayerPos:Vector3df = PlayerNode.getPosition() 'Position of Player
If (AsteroidNode.Size() > 0)
Local Ast:Int 'Current Array Element
For Ast = 0 To AsteroidNode.Size() - 1
Local AstNode:ISceneNode = AsteroidNode.elementAt(Ast) 'Current Asteroid Node
If (AstNode.isValid() = True)
If (AstNode.getPosition().getDistanceFrom(PlayerPos) > Radius And AstNode.getName() >< "Cave")
AstNode.Remove()
AsteroidNode.erase(Ast)
End If
End If
Next
End If
I could be removing the scenenodes incorrectly but, If I don't remove the scenenode before the element, the scenenode is not removed.