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 NutellaDaddy · Feb 20, 2014 at 11:59 PM · c#constantnewline

Newline in constant?

It says in the console that there is a newline in constant on every line. What does it mean and how do i fix it? Do you need all of my code to solve the problem? Please help!

 void GenerationMesh(){
             for (int x=0; x<chunkSize; x++){
                 for (int y=0; y<chunkSize; y++){
                     for (int z=0; z<chunkSize; z++){
                         //This code will run for every block in the chunk
                         
                         if(Block(x,y,z)!=0){
                             //If the block is solid
                             if(Block(x,y+1,z)==0){
                                 //Block above is air
                                 CubeTop(x,y,z,Block(x,y,z));
                             }
                             if(Block(x,y-1,z)==0){
                                 //Block below is air
                                 CubeBot(x,y,z,Block(x,y,z));    
                             }    
                             if(Block(x+1,y,z)==0){
                                 //Block east is air
                                 CubeEast(x,y,z,Block(x,y,z));        
                             }    
                             if(Block(x-1,y,z)==0){
                                 //Block west is air
                                 CubeWest(x,y,z,Block(x,y,z));        
                             }    
                             if(Block(x,y,z+1)==0){
                                 //Block north is air
                                 CubeNorth(x,y,z,Block(x,y,z));                            
                             }
                             if(Block(x,y,z-1)==0){
                                 //Block south is air
                                 CubeSouth(x,y,z,Block(x,y,z));    
                             }
                             
                         }
                         
                     }
                 }
             }
Comment
Add comment · Show 4
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 NutellaDaddy · Feb 21, 2014 at 12:08 AM 0
Share

Sorry it took the top part out of the code.

avatar image mattyman174 · Feb 21, 2014 at 12:18 AM 0
Share

Can you please provide the exact Error your receiving, dont paraphrase it as its very important exactly what it is.

avatar image NutellaDaddy · Feb 21, 2014 at 12:28 AM 0
Share

Assets/$$anonymous$$y Assets/Scripts/RandomGeneration/World.cs(48,0): error CS1010: Newline in constant

Its on every line from 48 to 94

avatar image NutellaDaddy · Feb 21, 2014 at 12:29 AM 0
Share

Full Script:

using UnityEngine; using System.Collections;

 public class World : $$anonymous$$onoBehaviour {
 
     public byte[,,] data;
     public int worldX=16;
     public int worldY=16;
     public int worldZ=16;
 
     public GameObject chunk;
     public GameObject[,,] chunks;
     public int chunkSize = 16;
 
 
     void Start () {
 
         for (int x=0; x<worldX; x++){
             for (int z=0; z<worldZ; z++){
                 int stone=PerlinNoise(x,0,z,10,3,1.2f);
                 stone+= PerlinNoise(x,300,z,20,4,0)+10;
                 int dirt=PerlinNoise(x,100,z,50,2,0) +1; //Added +1 to make sure $$anonymous$$imum grass height is 1
                 
                 for (int y=0; y<worldY; y++){
                     if(y<=stone){
                         data[x,y,z]=1;
                     } else if(y<=dirt+stone){ //Changed this line thanks to a comment
                         data[x,y,z]=2;
                     }
                     
                 }
             }
         }
 
         chunks=new GameObject[$$anonymous$$athf.FloorToInt(worldX/chunkSize),
                               $$anonymous$$athf.FloorToInt(worldY/chunkSize),
                               $$anonymous$$athf.FloorToInt(worldZ/chunkSize)];
         
         for (int x=0; x<chunks.GetLength(0); x++){
             for (int y=0; y<chunks.GetLength(1); y++){
                 for (int z=0; z<chunks.GetLength(2); z++){
                     
                     chunks[x,y,z]= Instantiate(chunk,
                            new Vector3(x*chunkSize,y*chunkSize,z*chunkSize),
                            new Quaternion(0,0,0,0)) as GameObject;
                     
                 Chunk newChunkScript= chunks[x,y,z].GetComponent(\"Chunk\") as Chunk;
  
                    newChunkScript.worldGO=gameObject;
                    newChunkScript.chunkSize=chunkSize;
                   newChunkScript.chunkX=x*chunkSize;
                    newChunkScript.chunkY=y*chunkSize;
                    newChunkScript.chunkZ=z*chunkSize;
     
               }
          }
     }
 
     
         data = new byte[worldX,worldY,worldZ];
 
         for (int x=0; x<worldX; x++){
             for (int y=0; y<worldY; y++){
                 for (int z=0; z<worldZ; z++){
                     
                     if(y<=8){
                         data[x,y,z]=1;
                     }
                     
                 }
             }
         }
     }
     public byte Block(int x, int y, int z){
         
         if( x>=worldX || x<0 || y>=worldY || y<0 || z>=worldZ || z<0){
             return (byte) 1;
         }
         
         return data[x,y,z];
     }
     int PerlinNoise(int x,int y, int z, float scale, float height, float power){
              float rValue;
              rValue=Noise.GetNoise (((double)x) / scale, ((double)y)/ scale, ((double)z) / scale);
              rValue*=height;
   
              if(power!=0){
                   rValue=$$anonymous$$athf.Pow( rValue, power);
              }
   
                  return (int) rValue;
         }
 }
 

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by mattyman174 · Feb 21, 2014 at 12:38 AM

 Chunk newChunkScript= chunks[x,y,z].GetComponent(\"Chunk\") as Chunk;

Where you define the Component type is incorrect. Remove the \ from the String as such.

 Chunk newChunkScript= chunks[x,y,z].GetComponent("Chunk") as Chunk;
Comment
Add comment · Show 3 · 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 Eric5h5 · Feb 21, 2014 at 12:41 AM 2
Share

Better yet, remove the quotes entirely.

avatar image mattyman174 · Feb 21, 2014 at 12:42 AM 0
Share

Haha that to...

avatar image NutellaDaddy · Feb 21, 2014 at 01:03 AM 0
Share

Thanks guys

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

21 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

Related Questions

C# Newline in constant. 1 Answer

Remove "new lines" from string variable? C# 2 Answers

Change Prefab Source/Change material on ALL prefabs in the scene 0 Answers

Change to constantly move forward 1 Answer

Destroying Cubes With OnCollisionEnter 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