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 /
avatar image
0
Question by TheCodeTrain · Jul 02, 2017 at 07:08 AM · array

Is there such thing as a TRIPLE ARRAY?

I have an int from another class, and the class is called PlayerScript1, and I am retrieving the int called "gameLevel" to get the current level, where I store it in the int localGameLevel. That data is checked in the animalLevelData1 list, where it scans what animals need to spawn in the scene. Then, I have another called "animalSpeed1" and this is the problem. It stores how fast the animal goes, depending what slot in the list that it is in. The code is animalLevelData1[animalLevelData1[localGameLevel]] because I am trying to retrieve data from another set of data. I keep getting the error: IndexOutOfRangeExeption: Array Index Out of Range. Is it not possible to retrieve data like that? or is there another solution? Any feedback is greatly appreciated. Thanks!

 public int[] animalLevelData1;
 public int[] animalSpeed1;
 private int localGameLevel;

      transform.position = new Vector3 (predatorPos.x += 
      animalLevelData1[animalLevelData1[localGameLevel]],predatorPos.y,predatorPos.z);


 void getLevel()
 {
     player = GameObject.Find ("Player1");
     localGameLevel = player.GetComponent<PlayerScript1> ().gameLevel;
 }




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 ShadyProductions · Jul 02, 2017 at 07:27 PM

The error means there is no such index in the given array for example:

 int[] abc = new int[2];
 abc[3] = 5; //index out of range because 3 does not exist

This is the case for you:

 animalLevelData1[animalLevelData1[localGameLevel]]

either the index of localGameLevel in animalLevelData1[localGameLevel] does not exist in your animalLevelData1 or it does exist the int and when you give the new int to animalLevelData1 again, it doesn't exist.

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 TheCodeTrain · Jul 05, 2017 at 05:48 PM 0
Share

Wow! This really helped. Thank you so much! I wasn't able to reward you with many points, as I am fairly new to Unity and answers.unity3d.com, but I gave you what I could give you. Thanks again, @ShadyProductions! You really helped me out!

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

115 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

Related Questions

how to check the bool of multiple object in an arrya. 0 Answers

Checking if a point is withing any of the colliders 1 Answer

Array 2D of data 1 Answer

Creating a Grid using an Array with C# 1 Answer

Storing delegates or function calls in a array 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