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 Ewok · May 11, 2011 at 01:31 AM · rangearray-out-of-range-exceptmultidimarray

Multi-Dimensional array out of range issues.

Hi. I'm working on something for a class that is a script for a virtual card game. I'm trying to make a multi-dimensional array that will pass a value to the two cards being drawn and remove them from the arrays so that they aren't drawn as duplicates. When I run the script it gives me an out of range exception that conflicts with the script my teacher wrote as the main engine. Here is my code:

class CardArraySetup {

     private static var instance : CardArraySetup = new CardArraySetup();

     public static function GetInstance() : CardArraySetup
     {
             return instance;
     }

     private var totalCardCount = new Array();
     private var multiDimensionGrid = new Array();
     private var flippedCards = new ArrayList();

     function GetCardArray() : Array
     {

             return totalCardCount;

     }

     function GetGridArray() : Array
     {

             return multiDimensionGrid;
     }

     function GetCardsFlippedArray() : ArrayList
     {

             return flippedCards;

     }

     function ResetCardsFlipped()
     {

     flippedCards = new ArrayList();
     }

     function GridSetup()
     {

                             for (i = 0; i < rows; i++)
                             {
                             multiDimensionGrid[i] = new Array();
                                     for (j = 0; j < column; j++)
                                     {
                                     var someNum : int = Random.Range(0, totalCardCount.length);

                             multiDimensionGrid[i][j]=totalCardCount;

                             totalCardCount.RemoveAt(i);
                             totalCardCount.RemoveAt(j);


                     }
             }
     }

}

Comment
Add comment · Show 3
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 Jessy · May 11, 2011 at 01:58 AM 0
Share

Why are you using all of these Arrays and ArrayLists? Is your $$anonymous$$cher forcing you to? It makes sense in web JS but it's obsolete for mono development.

avatar image Joshua · May 11, 2011 at 02:13 AM 0
Share

Other then the flipped cards array, why are they obsolete? I know you could do it a different way, but I wouldn't be able to say if that'd be more practical.

avatar image Ewok · May 11, 2011 at 04:24 AM 0
Share

To answer Jessy, yes I am being forced through it this way to $$anonymous$$ch how multi-dimensional arrays and arraylists work together in JS. I have a background in VBS and use arrays frequently at work in the IT field to push updates and modify settings and whatnot. The reason I'm so beside myself with this is the restrictive nature of the situation. I'm modifying a code, I guess piggyback style, to interface with his engine his way. It's a real bummer. As far as efficiency, I don't feel like getting into the relevance argument or debating whether lists work better than arrays or yatta yatta.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ewok · May 11, 2011 at 09:00 PM

So I've fixed everything but one issue. He says that my problem is my multi-dim array should be a sub-index of my totalCardCount that uses someNum to access that sub-index. This is where he lost me. So I at least know that the problem is specifically the multiDimensionGrid[i][j]=someNum; line because that is not what he's asking. Any and all help is appreciated. Random ego-boosting debate can please be directed to non-answer oriented forums. Thanks.

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

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

No one has followed this question yet.

Related Questions

Ai that applies damage when in range? 1 Answer

Unity Enemy Range detection 3 Answers

IndexOutOfRangeException 1 Answer

Shotgun range? 0 Answers

Detect If Object Is Within Range Of Player To Change Object Opacity 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