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 /
This question was closed Sep 01, 2015 at 04:44 PM by KlausJoensuu for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by KlausJoensuu · Aug 30, 2015 at 06:19 PM · c#javascripterrortextureout of range

Array index is out of range.

Ok i assigned the script to the terrain and i get a error that says:

"IndexOutOfRangeException: Array index is out of range. AssignSplatMap.Start () (at Assets/Terrain/Ground/Scripts/AssignSplatMap.cs:51)"

I have done everything right i think but it is just not working. Here is the full code. http://pastebin.com/2aTsVfvQ

I have three textures assigned to the terrain too. Terrain size is 10000 x 10000 If you know what wrong then please share! Thanks, -Klaus

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

  • Sort: 
avatar image
0
Best Answer

Answer by pako · Aug 30, 2015 at 08:29 PM

In line 35 of your code, you set the size of the splatWeights array to be equal to alphamapLayers:

 float[] splatWeights = new float[terrainData.alphamapLayers];


You don't post enough info to show what could be the possible values of alphamapLayers, but it seems that this value is smaller or equal to 3, and this is why you are getting the Array index is out of range error in line 51 of the script, which is:

 splatWeights[3] = height * Mathf.Clamp01(normal.z);


In this line of code you are setting the value of the 4th element of the array, which doesn't exist and you are getting the error. So, you must make sure that terrainData.alphamapLayers is always at least 4, in order to get rid of the error.

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 KlausJoensuu · Aug 30, 2015 at 11:24 PM 0
Share

Thank you millions kind sir! Im dumb that i didn't notice that but you saved lots of my time :) thanks again.

avatar image pako · Aug 31, 2015 at 08:56 AM 0
Share

You are welcome :-)

Follow this Question

Answers Answers and Comments

31 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

Related Questions

Trying to get animation to work. Problem with JS. 1 Answer

Error) DataReader already active on this command 0 Answers

Base64 to texture decoding, js -> webgl 1 Answer

Setting EventTrigger in Unity with JavaScript 0 Answers

NullReferenceException: Object reference not set to an instance of an object 3 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