• 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
Question by kamikadze1 · Jun 20, 2014 at 08:21 AM · androiderror

"function DoRoll (Point, Axis, Angle, Duration)" Does Not Work on Android. Any reasons?

 function DoRoll (Point,Axis,Angle,Duration) { 
  
  var tSteps = Mathf.Ceil(Duration * 30.0);  
  var tAngle = Angle / tSteps;  
  var pos : Vector3; // declare variable to fix the y position  
    
 // Rotate the cube by the point, axis and angle  
   for (var i = 1; i <= tSteps; i++)   
   {   
     transform.RotateAround (Point, Axis, tAngle);  
     yield WaitForSeconds(0.0033333);  
   }   
    
 // move the targetpoint to the center of the cube   
    transform.Find("targetpoint").position = transform.position;  
   
 // Make sure the y position is correct   
    pos = transform.position;  
    pos.y = startY;  
    transform.position = pos;  
       
 // Make sure the angles are snaping to 90 degrees.       
    var vec: Vector3 = transform.eulerAngles;  
    vec.x = Mathf.Round(vec.x / 90) * 90;  
    vec.y = Mathf.Round(vec.y / 90) * 90;  
    vec.z = Mathf.Round(vec.z / 90) * 90;  
    transform.eulerAngles = vec;  
       
 // The cube is stoped  
    ismoving = false;       
 }  




Here is my script. I have no Idea why does it gives t$$anonymous$$s error "Operator '*' cannot be used with a left hand side of type 'Object' and a right hand side of type 'float'." So I need your help. I tried to find answer in another questions like that, but unfortunately, i haven't.

The Error is in line " var tSteps = Mathf.Ceil(Duration * 30.0);
var tAngle = Angle / tSteps;
var pos : Vector3; // declare variable to fix the y position "

And The code is created by following instructions on "http://forum.unity3d.com/threads/how-to-move-camera-automatically.16190/"

And how to set "function DoRoll (Point,Axis,Angle,Duration) { " to "DoRoll(Vector3.zero, Vector3.up, 90.0, 1.0);"

Comment

People who like this

0 Show 7
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 tanoshimi · Jun 20, 2014 at 08:34 AM 0
Share

The line number accompanying the error message would have been helpful, but I'd guess it's to do with var tSteps = Mathf.Ceil(Duration * 30.0); - where do you declare Duration?

avatar image meat5000 ♦ · Jun 20, 2014 at 08:34 AM 0
Share

Is Duration a script? It's capitalised so I'd assume so. This would explain that error thrown by the line

 var tSteps = Mathf.Ceil(Duration * 30.0);

in which Duration is an object and 30.0 is a float. Obviously, the Ceil function doesn't support arguments of that type.

Of course I'm guessing as you've included no line numbers for you errors.

avatar image tanoshimi · Jun 20, 2014 at 08:37 AM 0
Share

And if you're building for mobile, you should really have #pragma strict declared at the top of your script, which should have picked up on the fact that you've not explicitly declared the type of any of your vars. e.g.

 var vec = transform.eulerAngles;

should be:

 var vec : Vector3 = transform.eulerAngles;
avatar image Benproductions1 · Jun 20, 2014 at 08:40 AM 0
Share

The solution: Type your variables.

avatar image meat5000 ♦ · Jun 20, 2014 at 08:41 AM 0
Share

You might have hit the nail on the head there.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Eric5h5 · Jun 22, 2014 at 07:46 PM

You must type all your variables.

 // wrong:
 function DoRoll (Point,Axis,Angle,Duration) {

 // right:
 function DoRoll (point : Vector3, axis : Vector3, angle : float, duration : float) {

Also, use lowercase for variable names. Uppercase is for classes and functions. I don't know if those are the correct types, by the way; that's just a quick assumption.

Comment

People who like this

0 Show 1 · 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 meat5000 ♦ · Jun 22, 2014 at 07:53 PM 0
Share

I feel stupid now...

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

unity crashes in android oreo because i set screen orientation to landscape 0 Answers

Android game crash startup 0 Answers

How can I convert this code to Unity Android? 1 Answer

[Solved] Reading text file on Android 2 Answers

Problem when trying to test an Android project! 0 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