Moving objects bug on game build (on other computers)

Hi everyone, I’ve got a bit of a head scratcher here. So in my game I have a moving object (here’s the code)

function Update()

{

if(transform.position.z<=30 && Time.time)
{
transform.position.z+=.04;
}
}

It may not be top notch but it gets the job done for the most part. Anyways, when I build and run my game these objects move exactly how they should, the slowly move along the z axis until they reach 30 then stop. However, when I build the game and send it to a friend it bugs out on him and the objects immediately go to 30 on the z axis. What makes it even stranger is this happens for two people but it works just fine for my other friend. I’m not certain how to go about solving this. At one point I heard a potential solution to this problem but that was such a long time ago I can’t remember where I heard it or what was the key to the solution.

I sincerely appreciate any info on this. Thanks

-Jeff Hyatt

Read that code to yourself and see if you can figure out what it means.

as often as possible (function Update), do the following:
if ( the transform has not passed +30 on the z axis AND ... time exists ) then
move the transform +0.04 units along Z

I’m very guessing you want this instead:

var metersPerSecond : float = 4;
function Update() {
  if ( transform.position.z <= 30 ) tranform.position.z += metersPerSecond * Time.deltaTime;
}

Different computers will run at different speeds; you have to use deltaTime to keep a consistent experience across machines.