❔ Out of bound error
I get this error :
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <f3aec01a34d14c7080754e28743c8472>:0)
Tore.GénérerBordures () (at Assets/Scripts/Tore.cs:82)
Tore.Awake () (at Assets/Scripts/Tore.cs:40)
and I don't really understand why it does that ngl. Here's the code for the 'tore' class (which basically creates a torus)
27 Replies
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/BlazeBin - ecbfhdwygysm
A tool for sharing your source code with the world!
Well, the error is quite clear
You have some collection of, say, 3 items, but you're trying to access the 4th one
Yeah ik, the index goes out of bound, but I don't get how that's possible
You should $debug then
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
I doubt I can use the debugger when it's attached to unity or maybe I can but don't know how to do it, since it's not the same
I tried
Yeah, but I see the error is in "générerBordures" but if you look at the error, it says the error is from tore.cs:82 right
Oh wait
Actually, the errors comes from line 82 right
but then, if you look at this (that creates pointstore)
I don't get how it goes out of index. I understand it does, but idk how
My bet is on
y + 1
being one too muchooh
Alright, so I have to find a way to get the left hand side differently than doing [y+1] - [y] which i don't even know why I,m doing
I mean, just a hunch
I might not be correct
But another way would be doing
I didn't check the code but are you sure its y <= x ?
Was about to say
Should probably be
<
not <=
Isn't that the same thing?
Yeah
oh wait no
I didn't do y < x which is basically list.count -1
I did
y <= x
you think that would fix it ?
I'll try
Samarichitane#3472
REPL Result: Success
Console Output
Compile: 585.474ms | Execution: 42.586ms | React with ❌ to remove this embed.
Did it output 5?
I mean You really need to write list.count-1 ?
Bro
I've been trying to fix this for the past 8 hours
You guys fkg saved my life
send me your paypal or smth 😂
🙏
Not needed also forbidden
ye ik
Hence why I put a laughing emoji
but god fkg damn it
Thank you guys
np
You can close the thread with /close
Thank you so much
Will do
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.