Bug / Crash ObiRopeCursor.ChangeLength causes IndexOutOfRangeExceptions - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Bug / Crash ObiRopeCursor.ChangeLength causes IndexOutOfRangeExceptions (/thread-2325.html) |
ObiRopeCursor.ChangeLength causes IndexOutOfRangeExceptions - protomenace - 20-06-2020 I'm trying to create a harpoon gun which is launched from a flying drone and hooks into whatever it collides with. The rope blueprint looks like this: [attachment=727] To shoot the harpoon, I'm starting with a very short rope, and increasing the length of the rope along with the velocity of the tip of my harpoon in FixedUpdate. The rope is attached to both the drone and the harpoon tip via ObiParticleAttachment. Code: using Obi; When I run this code, i get an IndexOutOfRangeExceptions in FixedUpdate after shooting the harpoon: Quote:IndexOutOfRangeException: Index was outside the bounds of the array. However the rope length still seems to change! So what am I doing wrong here? RE: ObiRopeCursor.ChangeLength causes IndexOutOfRangeExceptions - protomenace - 01-07-2020 I discovered some new information which may help fix this bug. I think it is related to the cursor not updating the particle index it is pointing to when the length of the rope is changed. I did a test where I created a rope with a cursor, and set the cursorMu to .5 Then I slowly reduced the length of the rope with cursor.ChangeLength(). Reliably, the error occurs after the length starts getting shorter than 1/2 of the original rope length. In other words, the cursor is pointing off the end of the rope! (Ignore the unrelated NullRefException at the top) [attachment=744] I was able to workaround the issue for now by setting the cursorMu every time just before calling ChangeLength(). |