Code will not work in standalone

The following code works perfectly in the Unity editor. No ifs, ands, or buts. But it will only do half of what I want it to do in the player. Here is the code:

function FixedUpdate () {
	if (inRange) {
		var lookAt = Vector3(chara.transform.position.x, transform.position.y, chara.transform.position.z);
		var rotationP = Quaternion.LookRotation(lookAt - transform.position);
		transform.rotation = Quaternion.Slerp(transform.rotation, rotationP, Time.deltaTime * 10);
		if (animate) BroadcastMessage("returnToZero", 0);
	}
	
	else {
		if (fwd) mod = -1;
		if (animate) BroadcastMessage(points[loco].gameObject.name, 0);
		
		if (points[loco + mod].gameObject.name == walkAniName) {
			if (Vector3.Distance (transform.position, points[loco].position) <= 5) loco = getNewPoint (loco);
			
			else { 
				var pointLook = Vector3(points[loco].position.x, transform.position.y, points[loco].position.z);
				var rotation = Quaternion.LookRotation(pointLook - transform.position);
				transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 1);
				var move = transform.TransformDirection(0, 0, speed * Time.deltaTime);
				transform.localPosition += move;
			}
		}
	}
}

When my character gets in range of the NPC, he turns and faces him as planned. But he is also supposed to walk and loop around some points I laid out as GameObjects. (The names of the GOs are the animation names that are broadcast to my animation script).

Any thoughts?

Not sure if it would make much difference in this particular case, but FixedUpdate is for applying physics forces; you should be using Update.

–Eric

No change.

I’ve had a simmilar problem. For some reason some mouse movement didnt work in the windows compile. I had a friend test the mac compile, and both that and the webplayer version worked fine. My only suggestion is that you start using the webplayer version… I can only assume that the windows compile system is somehow bugged :confused:

Probably some driver issue; I know mouse movement is fine in the Windows builds I’ve done on several different machines. There are at least a couple of third-party OS X mouse drivers where the mouse is fine in the editor, but is partially non-functional with a build.

–Eric

Drivers or not, I suggest trying the webplayer build. EDIT2: If you’re not already using the webplayer that is…

EDIT: oh, and another friend of mine on windows had the same problem when i send him the windows build, but that’s really off topic

Why not try cleaning it up?

function FixedUpdate () 
{ 
    if (inRange) 
    {
        var lookAt = Vector3(chara.transform.position.x, transform.position.y, chara.transform.position.z); 
        var rotationP = Quaternion.LookRotation(lookAt - transform.position); 
        transform.rotation = Quaternion.Slerp(transform.rotation, rotationP, Time.deltaTime * 10); 
        if (animate)
        {
            BroadcastMessage("returnToZero", 0); 
        }
   }
   else
   {
        if (fwd)
        {
            mod = -1;
        }
        if (animate)
        {
            BroadcastMessage(points[loco].gameObject.name, 0);
        }
        if (points[loco + mod].gameObject.name == walkAniName)
        {
            if (Vector3.Distance (transform.position, points[loco].position) <= 5)
            {
                loco = getNewPoint (loco);
            }
            else
            {
                var pointLook = Vector3(points[loco].position.x, transform.position.y, points[loco].position.z); 
                var rotation = Quaternion.LookRotation(pointLook - transform.position); 
                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 1); 
                var move = transform.TransformDirection(0, 0, speed * Time.deltaTime); 
                transform.localPosition += move; 
            }
        } 
    } 
}

I restarted my computer and all that good stuff. Maybe that will fix…

Still nothing. The points are gameObjects and do not have colliders. They’re active and stuff, but I set them on their own layer so the camera will not render them.