Car Tutorial Raycast Issue since Upgrade Unity 4, Build fails editor works

Hey Guys,

maybe someone has got the same issue since upgrading to U4.
I am working with the car tut alternatephysics model and since upgrading to u4
the game works normal in editor mode but the build gives me the following error from the wheel script:

raycastclosestshape:max distance must be greater than zero. at line4: bool onGround…

I double checked it within the console (printed: hit.point, hit.distance, hit.collider, hit.normal, and the starting point of the ray) and the distance the raycast gets is always greater than zero to the next shape.
I also put the wheel mesh out of raycast sight for a try…

I didnt change anything within the original CarTut Wheel script, so I dont really understand the problem.

Well I burned the whole last two days and I hope someones got an idea.

void FixedUpdate () {

		Vector3 pos = transform.position;
		up = transform.up;
		RaycastHit hit;
		bool onGround = Physics.Raycast( pos, -up, out hit, suspensionTravel +radius );
		//print ("Distance:" + (suspensionTravel + radius));
		if (onGround && hit.collider.isTrigger)
			onGround = false;
			float dist = suspensionTravel + radius;
			RaycastHit[] hits = Physics.RaycastAll( pos, -up, suspensionTravel +radius);
			foreach(RaycastHit test in hits)
				if (!test.collider.isTrigger && test.distance <= dist)
					hit = test;
					onGround = true;
					dist = test.distance;

		if (onGround)
			groundNormal = transform.InverseTransformDirection (inverseLocalRotation * hit.normal);
			compression = 1.0f - ((hit.distance - radius) / suspensionTravel);
			//print ("Compression:" + (1.0f - ((hit.distance - radius) / suspensionTravel)));
			print ("HitPoint:" + (hit.point));
			print ("Position:" + (pos));
			print ("Distance:" + (hit.distance));
			print ("Collider:" + (hit.collider));
			print ("Normal:" + (hit.normal));
			wheelVelo = body.GetPointVelocity (pos);
			localVelo = transform.InverseTransformDirection (inverseLocalRotation * wheelVelo);
			suspensionForce = SuspensionForce ();
			roadForce = RoadForce ();
			body.AddForceAtPosition (suspensionForce + roadForce, pos);
			compression = 0.0f;
			suspensionForce =;
			roadForce =;
			float totalInertia = inertia + drivetrainInertia;
			float driveAngularDelta = driveTorque * Time.deltaTime / totalInertia;
			float totalFrictionTorque = brakeFrictionTorque * brake + handbrakeFrictionTorque * handbrake + frictionTorque + driveFrictionTorque;
			float frictionAngularDelta = totalFrictionTorque * Time.deltaTime / totalInertia;
			angularVelocity += driveAngularDelta;
			if (Mathf.Abs(angularVelocity) > frictionAngularDelta)
				angularVelocity -= frictionAngularDelta * Mathf.Sign(angularVelocity);
				angularVelocity = 0;
			slipRatio = 0;
			slipVelo = 0;
		if (skid != null && Mathf.Abs(slipRatio) > 0.2)
			lastSkid = skid.AddSkidMark(hit.point, hit.normal, Mathf.Abs(slipRatio) - 0.2f,lastSkid);
			lastSkid = -1;
		compression = Mathf.Clamp01 (compression);
		rotation += angularVelocity * Time.deltaTime;
		if (model != null)
			model.transform.localPosition = Vector3.up * (compression - 1.0f) * suspensionTravel;
			model.transform.localRotation = Quaternion.Euler (Mathf.Rad2Deg * rotation, maxSteeringAngle * steering, 0);

Thanks ahead.

Well, the problem were two scripts used the same name, one in java the other in c#.
Deleted the unused one. Thats it.
The problem wasnt U4 and not the raycast. It seems U3… didnt took the script for the build.

I found the solution only lookin for someones with same problem: “build” is corrupted! Remove it and launch unity again!
This could be found in the output.log when to build a development build in front of the raycast issue.
So I ll always use this log in the future…

Maybe someones gettin the same struggle someday.