Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by The11thDoctor · Dec 17, 2013 at 07:39 PM · time.deltatime

Time class == null in Unity 4.3

Whenever I attempt to access Time.deltaTime, or any other member of Time, I get null. Prints, math, etc. with Time don't work. This is my code (below), but I also tried using the Scripting Reference Example code, and that didn't compile either. If anybody else has encountered this problem and has a solution or information that I could use, it would be much appreciated

 var go : boolean;
 var pages : int;
 var times = new Array();
 var average :double;
 var disTime : String;
 var sec : int;
 var min : int;
 var hour : int;

function Start () {

}

function Update () {

 if(go)
 {
     sec += Time.deltaTime;
     
     GetComponent(GUIText).text = "" + sec;
 }

}

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fafase · Dec 18, 2013 at 08:18 AM 1
Share

Do you have a class called Time in your project? Use the search bar to isolate if any.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by tanoshimi · Dec 17, 2013 at 07:42 PM

deltaTime is a float. You're trying to use it to increment sec, which is an int. Try making sec a float (and also call ToString() in the Update function)

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image The11thDoctor · Dec 18, 2013 at 01:16 AM 0
Share

Sorry about that. I fixed the incompatibility after the post, and recompiled. It still doesn't acknowledge the existence of class Time.

avatar image tanoshimi · Dec 18, 2013 at 07:40 AM 0
Share

What error message do you get?

avatar image The11thDoctor · Dec 18, 2013 at 07:02 PM 0
Share

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/Time.js:17)

The same error occurs when I try Time.time or other variables in that class.

avatar image tanoshimi · Dec 18, 2013 at 07:09 PM 1
Share

Your script is called Time.js? Try rena$$anonymous$$g it to, say, $$anonymous$$yTime.js

avatar image The11thDoctor · Dec 18, 2013 at 07:48 PM 0
Share

I just face palmed. Thanks, I should probably avoid na$$anonymous$$g my scripts after classes.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Delay Player From Using Action Button For A Period Of Time 0 Answers

Why does resetTimer act counter-intuitively? 2 Answers

Time.deltaTime High Score and Score count gives high score, but carries on counting it after saving with playerprefs 2 Answers

Projectile Physics - Why do i get a different result when using Time.sinceLevelLoad over Time.delatime in Unity? 1 Answer

Why can't I put transform.translate into a function in unity? (javascript) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges