I often receive annoying crash after that i have added some codes in AS script. So it looks the following - i write code in AS through CodeBlock IDE, save the script file, open the editor and get the unexpected error. ( http://imgur.com/a/tqsam )
Also i have noticed that if i delete these code (basically 2. PART), then all works fine.
class ArrowUI : ScriptObject
{
void Start()
{
// HERE START 1. PART
// Clear previous values
dirsResult.Clear();
dirsLong.Clear();
// Push initial values
dirsLong.Push(balloonNode.position);
dirsResult.Push(balloonNode.position);
// Set initial value
GoalPosition = balloonNode.position;
// Create 5 random points for the distance
for(int i = 0; i < 5; i++)
{
// Generate random rotation around Y axis
windDirs[i] = Vector3(0.0f, Random(0, 30), 0.0f);
// Generate random length along Z axis
dirsLong.Push(Vector3(dirsLong[i].x, 0.0f, dirsLong[i].z + Random(50, 500)));
// Rotate length according to generated random rotation around Y axis
Quaternion dirRot;
dirRot.FromEulerAngles(windDirs[i].x, windDirs[i].y, windDirs[i].z);
Vector3 goalPartDistance = dirRot * dirsLong[i + 1];
// Get the terrain
Node@ terrain = scene.GetChild("Terrain", true);
Terrain@ terrainComponent = terrain.GetComponent("Terrain", true);
// Get the height value
float height = terrainComponent.GetHeight(goalPartDistance);
// Set the returned height value to the new point of distance
goalPartDistance.y = height;
// Save the distance's point
dirsResult.Push(goalPartDistance);
}
// Save the goal position
goalPosition = dirsResult[5];
// Get the root check node
Node@ checkNode = scene.GetChild("CheckNode", true);
// Remove all childrens
checkNode.RemoveAllChildren();
// HERE START 2. PART
// Create 5 nodes for distance's generated points
for(int i = 0; i < 5; i++)
{
Node@ checkZone = checkNode.CreateChild("CheckZone_" + i);
checkZone.AddTag("CheckZone");
checkZone.position = dirsResult[i + 1];
RigidBody@ body = checkZone.CreateComponent("RigidBody");
body.trigger = true;
CollisionShape@ shape = checkZone.CreateComponent("CollisionShape");
shape.SetBox(Vector3(200.0f, 150.0f, 1.0f));
// Create the check zone logic object
checkZone.CreateScriptObject(scriptFile, "CheckZone");
CheckZone@ checkZoneComponent = cast<CheckZone>(checkZone.scriptObject);
checkZoneComponent.checkZoneId = i + 1;
}
}
}
class CheckZone : ScriptObject
{
int checkZoneId = 1;
bool isChecked = false;
}
So basically it removes old nodes, and create new nodes with new position in Start() method.
I suppose it may happens due to old nodes are removed from the scene. (checkNode.RemoveAllChildren()). But old nodes removing happens only in Start() method and in principle the error should not be though I can miss something.
There how looks crashdamp opened in VS2013.
http://imgur.com/a/jcx2D
In editor’s logs i do not get any errors.
Any ideas why i get crash and how can fix it ?
Thanks.