Obi Official Forum
Teleport() causing ArgumentOutOfRangeException error - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Softbody (https://obi.virtualmethodstudio.com/forum/forum-12.html)
+--- Thread: Teleport() causing ArgumentOutOfRangeException error (/thread-4137.html)



Teleport() causing ArgumentOutOfRangeException error - HakJak - 20-03-2024

Hello,

I was using Teleport() to reset out of bounds players and noticed it kept throwing an ArgumentOutOfRangeException error each time (ObiSoftbody.cs Line 189).  
I'm using Unity 2022.3.21f1 and a fresh install of the latest Obi Softbody asset on a basic project.  

I updated the script as show below (duplicated and commented out old for comparison).  It got rid of the error, but I'm not sure if it's correct or could cause other problems.  Please advise.  

Code:
for (int j = 0; j < ac.batches[i].activeConstraintCount && j < ac.GetBatchCount(); ++j)
{
    sc.batches[j].orientations[batchOffset + i] = rotOffset * sc.batches[i].orientations[batchOffset + j];
}

//for (int j = 0; j < ac.batches[i].activeConstraintCount; ++j)
//{
//    sc.batches[j].orientations[batchOffset + i] = rotOffset * sc.batches[i].orientations[batchOffset + j];
//}


Thank you

HakJak


RE: Teleport() causing ArgumentOutOfRangeException error - josemendez - 20-03-2024

Hi HakJak,

that code should read:

Code:
sc.batches[i].orientations[batchOffset + j] = rotOffset * sc.batches[i].orientations[batchOffset + j];


instead of


Code:
sc.batches[j].orientations[batchOffset + i] = rotOffset * sc.batches[i].orientations[batchOffset + j];


Notice the i and j variables in the left side of the = are swapped.

We should publish an update to address this one since Teleport() is a common operation.