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 BritDJL · Jun 02, 2015 at 01:23 PM · arrayprocedural

Why am I getting an error CS0103?

I'm sorry in advance, I'm relatively new to Unity.

I'm following this tutorial:

http://catlikecoding.com/unity/tutorials/procedural-grid/

and I'm at this state of the code:

using UnityEngine; using System.Collections;

 [RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
 public class Grid : MonoBehaviour {

 public int xSize, ySize;

 private Vector3[] vertices;

 private void Awake (){
     Generate();
 }

 private void OnDrawGizmos (){
     if (vertices == null){
         return;
     }        
     
     Gizmos.color = Color.black;
     for (int i = 0; i < vertices.Length; i++){
         Gizmos.DrawSphere(vertices[i], 0.1f);
     }
 }


 private void Generate () {
             vertices = new Vector3[(xSize + 1) * (ySize + 1)];
     for (int y = 0; y <= ySize; y++) {
         for (int x = 0; x <= xSize; x++) {
             vertices[i] = new Vector3(x, y);
         }
     }
 }
 }



On the highlighted part, in the private void Generate I'm getting a compiler error CS0103: 'The name 'i' does not exist in the current context' I'm 99% confident I've followed the tutorial and wrote the code verbatim, but I don't understand what I've done wrong.

Any help would be appreciated.

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
1
Best Answer

Answer by Landern · Jun 02, 2015 at 01:24 PM

Confusing, they had the UnityPackage link at the bottom of that post. Also the first for loop is with variable i and y:

 vertices = new Vector3[(xSize + 1) * (ySize + 1)];
 for (int i = 0, y = 0; y <= ySize; y++) {
     for (int x = 0; x <= xSize; x++, i++) {
         vertices[i] = new Vector3(x, y);
     }
 }

in the first for loop there was an i and y variable defined.

Comment
Add comment · Show 1 · 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 BritDJL · Jun 02, 2015 at 01:30 PM 1
Share

Oh god, cheers mate. I was looking so hard and getting a little stressed about it, I'm trying to follow it step by step so when I got that error it confused me. Thanks!

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

2 People are following this question.

avatar image avatar image

Related Questions

Does a Mesh Vertices/Triangles/etc Have to be Compact 1 Answer

Generate a mesh from randomly positioned points 0 Answers

Terrain Toolkit and Texturing via Code HELP! 1 Answer

Procedurally generated mesh JS - explain the error please 0 Answers

Procedural Mesh Generation - Split Arrays into sections 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