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 Arizodo · Sep 04, 2013 at 11:51 AM · scriptingbasicsscriptingproblem

What's wrong with this simple script?

Right now i get the this error when pressing the play button:

-Assets/Movement new.js(2,14): UCE0001: ';' expected. Insert a semicolon at the end.

This is the Script:


using UnityEngine.Transform;

 function Start () {
     
 }
 
 function Update () {
     if (Input.GetButton("Forward"))
     Transform.Translate(Vector3.forward);
 }

when i put a ; after the identifier "using" like Unity tells me to. (Which would make no sence.) I get the following errors:

-Assets/Movement new.js(9,27): BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'Translate'.

-Assets/Movement new.js(1,1): BCE0005: Unknown identifier: 'using'.

-Assets/Movement new.js(1,20): BCE0034: Expressions in statements must only be executed for their side-effects.


So i can't figure out whats wrong, i just started scripting, and i believe everything in there is right. (Although i am appearantly horribly wrong. If there is something wrong with it please tell me, it's kinda really bugging me.

EDIT: thanks everyone, it's now fixed, but now i have another problem, i added some stuff, and now it gives me an error about a non-existant line, how can i solve this?

Updated script:


import UnityEngine.Transform;

function Start () {

}

function Update () { if (Input.GetButton("Move Forwards")) transform.Translate(Vector3.forward);

 {
     if (Input.GetButton("Move Backwards"))
     transform.Translate(-Vector3.forward);
 }

Accompanied By the error: Assets/Movement new.js(16,1): BCE0044: expecting }, found ''.

That's what i find weird, since there is no sixteenth line. This happend to my previous scripts as well, making them all unuseable.

EDIT2: Nevermind, i managed to fix it.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by PAEvenson · Sep 04, 2013 at 11:57 AM

change this:

 Transform.Translate(Vector3.forward);

to:

 transform.Translate(Vector3.forward);
Comment
Add comment · Show 5 · 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 robhuhn · Sep 04, 2013 at 12:01 PM 1
Share

Also 'using' is a c# keyword. It's 'import' in US isn't it?

avatar image PAEvenson · Sep 04, 2013 at 12:04 PM 0
Share

Yes, 'import' for UnityScript and 'using' for c#.

avatar image PAEvenson · Sep 04, 2013 at 12:05 PM 0
Share

you do not need to import UnityEngine.Transform. You can remove that line completely.

avatar image Arizodo · Sep 04, 2013 at 12:48 PM 0
Share

Unity says that i in fact need the UnityEngine.Trasfor.translate

and it said using in the Official tutorial on the Unity site, so i went with that.

avatar image hammil · Sep 04, 2013 at 01:01 PM 0
Share

'Transform' refers to the Transform class itself, whereas 'transform' refers to the instance of said class attached to the gameobject. Confusing, I know, but the casing is consistent throughout Unity.

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

variables within variables? 2 Answers

Animator Controller 0 Answers

Junior Programming Pathway scaling a cube 2 Answers

Issue with animation and gravity. 1 Answer

Help with script please, boss and destroyed message 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