• 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 Robgar2001 · Aug 10, 2017 at 05:54 PM · bugtransform.positionvector2floats

Why does the code stops?

First of all excuse me for my bare English. If i run the code with the commands (//) enabled it will not do the calculation (will not print "is voorbij") (i tested t$$anonymous$$s by printing a text message after the calculation is done). With those lines of code as a command // it works fine. Can somebody explain t$$anonymous$$s to me?

   public int count;
     public GameObject enemy;
     public Transform spawn;
     void Start () {
         count = (int)Time.realtimeSinceStartup;
         EnemySpawnController ESC = new EnemySpawnController();
         ESC.CheckIfFree();
     }
     public void GoTOLocation(string name) {
         print ("Searc$$anonymous$$ng for gameobject with name:" + name);
         spawn.Find ("1");
 
         print ("x." + spawn.transform.position.x + "/" + spawn.transform.position.y);
 
 
         Vector2 diff;
         //diff.x = spawn.transform.position.x-gameObject.transform.position.x;
         //diff.y = spawn.transform.position.y-gameObject.transform.position.y;
 
         print ("is voorbij");
 
         if (x != enemy.transform.position.x) { gameObject.transform.Translate(Vector2.right * diff.x); }
         if (y != enemy.transform.position.y) { gameObject.transform.Translate(Vector2.up * diff.y); }
     }
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by TheSOULDev · Aug 10, 2017 at 06:17 PM

// is commenting, meaning that anyt$$anonymous$$ng after // in a line won't be compiled.

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 arain55 · Aug 10, 2017 at 06:22 PM

Hi @Robgar2001 , those are comments and they are not executed by the compiler and are only there for the people writing the code or reading the code to inform them what that line of code does. eg:

 //t$$anonymous$$s line prints Hello world to the unity console
 print("Hello world") 
 the line above will print Hello world to the unity console and the comment above describes what it does.
 
 //print("Hello world")
 that will print not$$anonymous$$ng as it is ignored by the compiler, in other words it is not executed.

there are two types of comments multiline and one line

look here for more info: http://www.c-sharpcorner.com/uploadfile/puranindia/comments-in-C-Sharp/

and please before you start using unity learn a programming language, such as C# and that will avoid questions such as t$$anonymous$$s w$$anonymous$$ch are unnecessary

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 Robgar2001 · Aug 10, 2017 at 07:52 PM

@arain55 @TheSOULDev I know i know but i mean when i remove the // the code won't print the "is voorbij" message. So those two lines avoid the computer to print the "is voorbij" message. And i want to know why those lines avoid that. (I know how the command system works)

Comment
Add comment · Show 2 · 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 arain55 · Aug 10, 2017 at 11:48 PM 0
Share
avatar image Robgar2001 arain55 · Aug 11, 2017 at 03:06 PM 0
Share

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

74 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

Related Questions

Rigidbody2D.Velocity = Vector2 not changing X Position 1 Answer

Player Swap position 1 Answer

Not able to fire projectiles at mouse position 2 Answers

moving objects with transform position 2 Answers

Change animation at runtime with Mecanim 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