x


Time.deltaTime always null

Trying to create a simple chronometer:

var minutes : int = 0; var seconds : float = 0.0;

function Update () {

seconds = seconds + Time.deltaTime;

if(seconds >= 60){
    minutes++;
    seconds = seconds - 60;
}

Debug.Log(minutes + " : " + seconds);

}

I always get an error:

NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs) Time.Update () (at Assets/Scripts/Time.js:6)

I also tried this tutorial and the code that was working fine in the video gave the same error for me again. Plus puting the Time.deltaTime in Debug.Log only shows Null...

So I am stuck at this now :(

more ▼

asked Aug 24 '11 at 07:56 PM

Eddy Johnson gravatar image

Eddy Johnson
18 5 5 10

Please format your code properly.

Aug 24 '11 at 08:12 PM Eric5h5
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can't call your script the same thing as a Unity class*, because then it's looking inside your Time script for deltaTime, which of course does not exist.

* Unless you distinguish between them by specifying UnityEngine.Time, but that's a bit of a pain.

more ▼

answered Aug 24 '11 at 08:11 PM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x394
x64

asked: Aug 24 '11 at 07:56 PM

Seen: 660 times

Last Updated: Aug 24 '11 at 08:20 PM