Curious Problem - part of a script works in development environment - not in a build!

I have a really weird problem. For a puzzle game, the path of the solution gets traced by rotating a cube when the player finishes a level.

This works perfectly in the Unity Development Environment (I’m using Unity 3.4, and I’ve tried this issue in both non-Pro and Pro versions). However, the code that rotates the cube, for some reason, does NOT work in the build. The rest of the script works perfectly, just that one little part of the script does not.

Here is the little bit of code that rotates the cube:

Camera.main.transform.rotation = Quaternion.Lerp(Camera.main.transform.rotation, cameraRot, Time.deltaTime);
cameraPos = Camera.main.transform.rotation * new Vector3(-0.06848729f, 0.0f, -1.0f) + cube.transform.position;
Camera.main.transform.position = Vector3.Lerp(transform.position, cameraPos, Mathf.SmoothStep(0.0f, 1.0f, (Time.deltaTime * 10)));

Anyone have any ideas? Or ever had a similar experience?

how do you assign the cameraRot variable?
Why using Quaternion.Lerp and not Slerp?
It might be that Time.deltaTime is very close to 0 in the build and Quaternion.Lerp returns the camera’s current rotation or something very close to it.

I assign cameraRot in the following way:

cameraRot = Quaternion.Euler(90.0f, 180.0f, 0.0f);

I haven’t tried using a Slerp. Maybe that would work better for what I’m doing?

And I will try to log Time.deltaTime to check on your final point.

Thanks! :slight_smile:

I should clarify.

The rotation works fine in the build. But the position gets messed up so that the object that is being rotated around gets clipped by the camera.

I changed both lerps to slerps, and increased the coefficient on the position slerp’s Time.deltaTime, and now it works great.

Thanks for the response! :slight_smile: