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
1
Question by daves · Nov 15, 2011 at 11:07 AM · androiderrorioserror-building-player

Vector3 and Object build errors

Building an fps game for the android/ios, the following two errors appeared when trying to compile the code:

Assets/ZombieScripts/FemZombiev1_AI.js(183,29): BCE0051: Operator '*' cannot be used with a left hand side of type 'UnityEngine.Vector3' and a right hand side of type 'Object'.

Assets/ZombieScripts/FemZombiev1_AI.js(186,39): BCE0051: Operator '*' cannot be used with a left hand side of type 'Object' and a right hand side of type 'float'.

Am i right to understand that this error relates to the calling of the object within the script? All variables are defined within the same script, and compiled correctly for the web versions.

Or if not, can anyone direct me on what the issue is, and ideas on how to fix it,

Thanks, D

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 syclamoth · Nov 15, 2011 at 11:10 AM 0
Share

Well, presumably it's because you're attempting to multiply an 'Object' with a Vector3 or a float! In this case, I'd blame Javascript's fuzzy typing- try forcing each member to have an explicit type. Could you post the specific lines involved there? The problem might be somewhat more in-depth. Just knowing the name of the error is not enough to be able to fix it, only enough to know what is causing the problem.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Caiuse · Nov 15, 2011 at 11:16 AM

I found that when programming iOS game in Unity you have to be a little more precise with you declarations.

the variables that you are trying to * have to have a type declared.

for example :

 for(element in anArray){
     var result = element * 10.0;
 }

will not work, where as this will:

 for(element : float in anArray){
     var result = element * 10.0;
 }

Hope this helps - Caius

Comment
Add comment · 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
0

Answer by daves · Nov 15, 2011 at 11:48 AM

The two lines of code which present the two errors:

The 'Object' related error:

direction = forward * speed * speedModifier;
GetComponent (CharacterController).SimpleMove(direction);

The float related error:

SendMessage("SetSpeed", speed * speedModifier, SendMessageOptions.DontRequireReceiver);

Thansk for advice so far, will continue to have a look at this, as these two errors are present in 22 other files using a similar structure.

Thanks, D

Comment
Add comment · 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 syclamoth · Nov 15, 2011 at 11:53 AM 0
Share

Well, as Caius said, make sure that all your variables are being explicitly typed! Where you would have used

 var speed = 100;

ins$$anonymous$$d explicitly make it a float-

 var speed : float = 100;

This way, you won't have compile errors telling you that you are using the wrong types.

tl;dr This is why you should use C#, this stuff is frustrating as hell to deal with.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Android not working 1 Answer

Vuforia Plugin Issues with Computer and Android 0 Answers

Unity Editor & iOS - Download MP4 to Streaming Assets Folder 0 Answers

AdMob iOS and Android 1 Answer

Error building player when run on Asus Transformer Prime with android 4.0.3 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