-Content Deleted-

[Content Deleted]

Did you copy the script properly? Because technically there can’t be an error on line 79. Perhaps it’s line 77?

That’s quite rude of you to assume that I’m attempting to cheat him. He gave up, I made him aware of the glitch and he told me to just take the script for free because he doesn’t want to fix it.

Whew, well that’s good to know, and I’m sorry for the assumption. I’ve edited my reply, as I’m not sure where you’re getting the error. Also, there’s a Biome class being referenced, so the issue could be from there as well.

Thanks, and yes I just re-pasted it and now it’s line 80, unity forums is just being weird I guess

EDIT:
Fixed, it’s line 79 now

EDIT 2:
Added Biome.cs

I seem to be missing something as I can’t make the script work in a new scene, but I think I know the problem. In the Initialize() function, it sets the splatMapData (line 57). However, when you resize the terrain, you aren’t updating the splatMapData size. So you could put that line in a Update function for a sloppy fix, or call it every time you change the size of the terrain.

I’m not changing the size of the terrain mid-game though.

And to make the script work you place it on the terrain, you don’t need to place down Biome.cs, then you assign the terrain variable to the terrain you have the script placed on.

Thanks for the explanation, I did that and it works.

I’ve changed the Terrain width and length both in the Editor and during game runtime with no errors. Is there anything I’m missing out on?

I can’t explain it, I create some terrain, add a few textures, draw on the map, change the map size, then add the script and it doesn’t work.

Perhaps the problem hasn’t been the terrain size, but rather something to do with the textures?

I just tested it, spawning in default terrain - adding a texture and changing the width/length. It then throws me an error so it definitely is a size problem

BIG EDIT:
I just tested it out, re-sized terrain that DOESNT have a texture it works on! So somehow adding a texture is causing the problem

Originally I was testing a terrain without textures as well, but I’ve added 3 textures, drawn a bit on the terrain, then resized it in the Terrain Settings, both out of and in-game, with no errors. No wonder the original programmer gave up, I can’t even reproduce the error lol

I’ve also posted a video, showing what I’ve done:

He said he couldn’t reproduce it either! I can’t see, what version of Unity are you running?

Also, have you tried making the terrain larger instead of smaller? Like, try 2000x2000

Also, I’ve noticed you didn’t even add anything to the biomes

I finally got the error when I made the terrain 800 X 600.

IndexOutOfRangeException: Array index is out of range.
(wrapper managed-to-managed) object:ElementAddr_3_4 (object,int,int,int)
TESTPlacerScript.Spawn () (at Assets/@MYSTUFF/Scripts/TESTPlacerScript.cs:79)
TESTPlacerScript.Start () (at Assets/
@MYSTUFF/Scripts/TESTPlacerScript.cs:34)

Also, I did add biomes:
3068547--230696--upload_2017-5-13_13-41-44.png
Very perplexing…

So we can confirm then that the problem occurs when both of these conditions are met:
A) The terrain has textures
B) The terrain size is larger than default

I slightly contest that, it works for sizes a bit larger than 500X500, I’ve had success with 530X530. But 550X550 is enough to trip the error. I’m currently thinking the array is getting too big.

Most people would give up by now, but I’ll chalk this up as C# practice.

Thanks, it would mean the world if I could get this running because it is quite literally one of the biggest gameplay-required mechanics I need to get my game going

I’m not sure if this will work for you, and I’m pretty sure this isn’t good programming practice, but this just catches the error so it doesn’t show and/or crash and from my experience, it seems to work OK:

for (int i = 0; i < mTextures; i++)
{
    try
    {
        if (comp < splatMapData[(int)TerrainCord.z, (int)TerrainCord.x, i])
            ret = i;
    }
    catch {}
}

Give that a try and see if it works OK (replace the lines between about 77-81 with that). It works with even 5000X5000 terrains and spawns objects like it does at 300X300.

It appears to work! Thanks a ton, now I’m going to test if it works properly on my current islands (im in a test scene atm)

Let me know!! Fingers crossed