Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 frmusta · May 12, 2010 at 06:58 PM · floatintconvert

Cannot convert 'callable(int) as float' to 'float'.

What is the correct way to do this type of conversion?

What im doing is getting information from an XML file, converting that text into a float with parseFloat. Trying to pass this number directly into a yield waitForSeconds(); call gives me the following error:

Cannot convert 'callable(int) as float' to 'float'.

What am i doing wrong here? Simple mistake? Thanks for your time!

EDIT- here you go, scripts to follow.

xml get data script :

var waitTimeNext: float;

function start() { var tempWaitTimeNext: String = stepNode.GetValue("wait>2>_text"); tempStepObj.waitTimeNext = parseFloat(tempWaitTimeNext); }

script with yield :

        var c : float = (lessonDataScript.getStepWaitTimeNext);
        yield WaitForSeconds (c);

Comment
Add comment · Show 2
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 Mike 3 · May 12, 2010 at 07:06 PM 0
Share

could you post the code?

avatar image frmusta · May 12, 2010 at 07:14 PM 0
Share

ok edited with the code!

1 Reply

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

Answer by burnumd · May 12, 2010 at 07:29 PM

What is "getStepWaitTimeNext?" Is that a function that returns the value in "tempStepObj.waitTimeNext?" If so, you need to put parentheses after it to call it. Otherwise, you're trying to put a callable (or function definition) into that float value, c.

Comment
Add comment · Show 3 · 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 burnumd · May 12, 2010 at 07:30 PM 0
Share

As a sidenote, this issue is an example of when proper formatting can really help. If "getStepWaitTimeNext" were a function that started with a capital letter (as should "start ()" in your example above), we could see right away that it ought to have parentheses after it. As it is, I don't know if getStepWaitTimeNext is a function or a variable that ought to be a float, but I'm guessing that's what the problem is.

avatar image frmusta · May 12, 2010 at 07:34 PM 0
Share

You guys are right, i forgot the () after getStepWaitTimeNext.. sheesh. Sorry about the stupid question :/

avatar image burnumd · May 12, 2010 at 07:49 PM 0
Share

Everyone does it sometimes, and it's a difficult error message to figure out if you don't realize that "callable" essentially means "function" (for certain definitions of "function"). :)

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

No one has followed this question yet.

Related Questions

Convert Text to float 3 Answers

Convert a char to int / float 2 Answers

Turn float to int 2 Answers

Cannot implicitly convert type `float' to `int'. An explicit conversion exists (are you missing a cast?) 1 Answer

Possible to convert a Float into an Int? 3 Answers


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