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 /
  • Help Room /
This question was closed Nov 28, 2017 at 12:16 AM by NEGATIVERAGDOLL for the following reason:

The question is answered, right answer was accepted

avatar image
-1
Question by NEGATIVERAGDOLL · Nov 23, 2017 at 05:09 AM · javascriptscript.error messagesemicolon

';' expected. Insert a semicolon at the end. Already have one

Not sure what is happening, here's my script. Happen on "float dist" line.

   #pragma strict
  
 var item : GameObject;
  
 function Start () 
  {
   gameObject.transform.localRotation = Quaternion.Euler(0,0,0);
  }
  function Update()
  {
        if(Input.GetKeyDown(KeyCode.E))
         {
                     float dist = Vector3.Dist(object.positon,player.position);
                     if(dist<minDist)
                     {    
                          pickup();
                      }
           }
  }

Comment
Add comment · Show 14
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 Hellium · Nov 23, 2017 at 02:35 PM 0
Share

Try :

 float dist = Vector3.Dist(gameObject.transform.positon,player.transform.position);
avatar image Hellium · Nov 23, 2017 at 09:06 PM 0
Share

@NEGATIVERAGDOLL : Have you solved your issue?

avatar image NEGATIVERAGDOLL Hellium · Nov 24, 2017 at 02:37 AM 0
Share

Just tried. Nope the error still comes up, I'm not sure what I have done wrong

avatar image Hellium NEGATIVERAGDOLL · Nov 24, 2017 at 04:12 PM 0
Share

Where does the error occur?

Show more comments

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Hellium · Nov 26, 2017 at 11:41 AM

 #pragma strict
   
 var item : GameObject;
 var player : GameObject;
 var minDist : float;
   
 function Start () 
 {
     gameObject.transform.localRotation = Quaternion.Euler(0,0,0);
 }
 function Update()
 {
     if(Input.GetKeyDown(KeyCode.E))
     {
         var dist : float = Vector3.Distance(transform.position,player.transform.position);
         if(dist<minDist)
         {    
             pickup();
         }
     }
 }
 
 function pickup()
 {
     // ....
 }
Comment
Add comment · Show 14 · 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 Hellium · Nov 26, 2017 at 11:56 AM 0
Share

If you still have the message in your IDE (like me), but no error in Unity, it's fine.

avatar image NEGATIVERAGDOLL · Nov 26, 2017 at 12:04 PM 0
Share

Thank you for this. This fixes the error. The only problem I am now having is I'm trying to add a "Destory(gameObject)" part to the end so that once the function is called the item will be destroyed i.e the player picking it up.

avatar image Hellium NEGATIVERAGDOLL · Nov 26, 2017 at 12:06 PM 0
Share

Simply put Destroy( gameObject ); inside the pickup function

avatar image NEGATIVERAGDOLL Hellium · Nov 26, 2017 at 12:15 PM 0
Share

I just added it in and still does not destroy the game object. I'm really sorry for see$$anonymous$$g like I have no idea what I'm doing

Show more comments
avatar image NEGATIVERAGDOLL · Nov 27, 2017 at 10:05 AM 0
Share

Okay just got a script working. Thank you for the help!

Follow this Question

Answers Answers and Comments

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

Related Questions

Getting error on lap counter script JS 0 Answers

How do I make a enter and exit car script? 0 Answers

error CS1503 Cannot convert method group to string. 1 Answer

"The associated script cannot be loaded" 0 Answers

Unable to join player connection alternative multicast group. 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