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 Amm1992 · Jun 05, 2014 at 11:45 AM · errorbce0044bce0043

Converting My JS code into UnityScript

So I recently learnt JavaScript at a beginner level but was able to make some basic things like a fruit machine, dice game and a simple dodging game. But I am trying to figure out the main difference between UnityScript and JavaScript and to do this I thought I would try to import my code and alter it to work with unity.

So this is my issue I created a simple thing to suggest the characters position and alter it when the user presses the left or right key (I am aware many of it is probably wrong but I am learning), however Unity passes some errors which makes me wonder.

The Errors I have received that baffle me are:

  • PlayerController.js(9,26): BCE0044: expecting ), found '='.

  • PlayerController.js(9,27): BCE0043: Unexpected token: >.

So to summarise I am asking if this is wrong why? and does this mean Unity does not accept a simple => to check that a variable is equal to or greater than a value/function and if that is the case what should I use instead.

Thank for any help the code is below.

 var posX = 0;
 var maxLeft = -10;
 var maxRight = 10;
 
 function Update()
 {
     if (Input.GetButton("left")) 
     {
         if (posX => maxLeft)
         {
             //If the position is equal to maxLeft then it will not do anything.
         }
         else
         {
             //Move character left on screen;
             posX = posX-0.5;
             transform.position = (0, posX, 0);
         }  
     }
     else if (Input.GetButton("right"))
     {
         if (posX => maxRight)
         {
             //If the position is equal to maxRight then it will not do anything.
         }
         else
         {
             //move character right on screen;
             posX = posX+0.5;
             transform.position = (0, posX, 0);
         }
     }
     else
     {
     //Left or Right arrow key not pressed so do nothing.
     }
 }
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 Graham-Dunnett ♦♦ · Jun 05, 2014 at 11:47 AM 0
Share

http://answers.unity3d.com/questions/topics/bce0044.html http://answers.unity3d.com/questions/topics/bce0043.html

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Graham-Dunnett · Jun 05, 2014 at 11:46 AM

Well, the errors say the problem is on line 9. Line 9 should be:

 if (posX >= maxLeft)

Also, next time, look up the error you get on the tags section of this site.

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

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

23 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 avatar image avatar image avatar image avatar image

Related Questions

3 java errors on a basic shooting script? 2 Answers

Please help, syntax error woe 2 Answers

How can solve these errors in my java script 1 Answer

SwipeControl package error in unity iPhone 1.7 1 Answer

BCE0043 Unexpected Token: Please Help! 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