Game crashing when adding CharacterController to a GameObject.

Hi there.

I’m having this strange problem: in my game there are 50 avatars coming in an out from a scene, each one with a CharacterController to deal with movement and collisions…
Sometimes, upon instantiation of one of these avatars, the game crashes, informing the following error on output_log.txt:

error.log says that its some access violation problem:

i’ve isolated the part of the code where its most likely to be where the problem resides:
(l_newAvatar is a not null GameObject)

CharacterController l_controller = l_newAvatar.AddComponent<CharacterController>();

I know this is (probably) not enough information to find out what is exactly the problem, but I would apreciate if someone could give me some pointers to solve this problem.

Thanks in advance.

Do you have any code in the CharacterController’s constructor/awake/start methods? Any initialization values for its member variables that are derived by calling a method? Perhaps its some exception being thrown in those which causes it to not properly run AddComponent.

All I know about CharacterController class is here:

Come on UT people, u should know what could cause that stuff… I have no access to CharacterController code…

This isn’t the first problem I got on Unity’s Character Controller since they launched Unity 3.

Someone from UT could please help us with our problems or at least give us some directions to solve them?

That is always the problem with closed source software. Something gets screwed up and the developers don’t know what it is, don’t have time or simply it is not worth in financial terms to do something. Then the ones who have interest in fixing can’t do nothing but wait =\

The way i solved this problem was downgrading to Unity 2.6 … it really is not a solution, but given the situation and the information available (practically none) it was the only way i found to have my app running

@fellipemi: Is there any more information you can give about the l_newAvatar object? What components are already on that object when the offending code gets called? Can you post the rest of the Update function where the component gets added?

andeeee, thanks for replying.

Animation
SkinnedMeshRenderer

and 4 more components to perform basic actions, like highlight when mouse over, sync animations, sync transform and avatar customization.

private void Update()
    {
        if (s_avatarQueue != null  s_avatarQueue.Count > 0)
        {
            GamePlayer l_newPlayer;
            GameObject l_newAvatar;

            l_newPlayer = new GamePlayer();

            l_newAvatar = l_newPlayer.GetAvatar();         

            l_newPlayer.UpdateAvatar();
            l_newAvatar.transform.position = Vector3.zero;

            l_newAvatar.AddComponent<PlayerInteraction>();

            //Setting the right animation
            NetSyncAnimation l_netAnimation = l_newAvatar.AddComponent<NetSyncAnimation>();
            l_newAvatar.AddComponent<NetInterpolatedTransform>();

            CharacterController l_controller = l_newAvatar.AddComponent<CharacterController>();
            l_controller.height = 0.4f;
            l_controller.radius = 0.09f;
            l_controller.slopeLimit = 10;
            l_controller.stepOffset = 0.005f;
            l_controller.center = new Vector3(0, 0.29f, 0);

            PathSeeker l_pathSeeker = l_newAvatar.AddComponent<PathSeeker>();
            l_pathSeeker.SetRemote(true);

            l_netAnimation.StopAction();
            l_netAnimation.SyncAnimation();
        }
    }

At first i thought that the engine could be having some trouble allocating memory for the CharacterController, but there is a considerable amount of free memory when the game crashes…

So… there is any solution for our problem?

Sorry to bring up an old topic, but I am getting the same error: " Supplied NxActor Desc is not valid. createActor returns NULL." With an object that doesn’t even have a character controller, and is just simply an object that is designed to receive the mouse input from the “sphereManager” (sphereManager.mouseCoordinates) - which has a large collider that is getting the mouse coordinates and clicks, and, using those values, to become a sort of “Stretch Block” that goes between those two points. But, sometimes when the user clicks to place this block, then instantly releases their click (creating a block with a x and y scale of 0), it returns this error - while also deleting the block - which is intentional and found in the:

if(initialPosition == sphereManager.mouseCoordinates){
Destroy(gameObject);
}

part of the code, but, the error is not, and I can’t really find a solution to in anywhere, because there is really no way to know what it’s taking about. Any advice or help?

var sphereManager : SphereManager;
private var initialPosition : Vector3;
var going : System.Boolean = true;
function Start () {
	if(going){
		transform.localScale.z = 1;
		sphereManager = GameObject.Find("SphereManager").transform.GetComponent(SphereManager);
		initialPosition = sphereManager.mouseCoordinates;
		transform.position = initialPosition;
		if(!rigidbody){
			gameObject.AddComponent(Rigidbody);	
			rigidbody.mass = 100000;
		}
	}
}
function Update () {
	transform.localScale.z = 1;
	if(going){
		if(rigidbody){
			transform.localEulerAngles = Vector3(0,0,0);
			rigidbody.velocity = Vector3(0,0,0);
			rigidbody.angularVelocity = Vector3(0,0,0);	
		}
		transform.position = Vector3((initialPosition.x + sphereManager.mouseCoordinates.x)/2,(initialPosition.y + sphereManager.mouseCoordinates.y)/2,initialPosition.z);
		transform.localScale.x = Mathf.Abs(initialPosition.x - sphereManager.mouseCoordinates.x);
		transform.localScale.y = Mathf.Abs(initialPosition.y - sphereManager.mouseCoordinates.y);
		if(sphereManager.leftClickObject.transform.GetComponent(StretchBlock)){
			if(sphereManager.leftMouseDown == false){
				going = false;
				if(rigidbody){
					Destroy(rigidbody);	
				}
				if(initialPosition == sphereManager.mouseCoordinates){
					Destroy(gameObject);
				}
			}	
		}
		if(sphereManager.rightClickObject.transform.GetComponent(StretchBlock)){
			if(sphereManager.rightMouseDown == false){
				going = false;
				if(rigidbody){
					Destroy(rigidbody);	
				}
				if(initialPosition == sphereManager.mouseCoordinates){
					Destroy(gameObject);
				}
			}	
		}
	}
	
}
function MidPoint(start : Vector3, end : Vector3) : Vector3{
        return Vector3(  (start.x+end.x)/2  ,  (start.y+end.y)/2  ,  (start.z+end.z)/2  );
}

Me too. No idea what the issue is; claims it’s on a SetActiveRecursively line…

Cheers