Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ropes Lagging
#4
Hi,

Every frame you're creating a new list, and for each contact you're removing Rope components from this list. I don't know how often this happens, but it has the potential to be slow (and cause a lot of GC).

Removing entries from a list has linear cost in the amount of elements in the list: the entire list has to be searched for the element being removed, then all elements past it have to be moved one entry back. So for each pair of particles in contact, you're iterating trough all ropes in the allNonCollidingRopes list multiple times. If you have more than a handful of ropes in the allNonCollidingRopes list, this will be *very* slow.

I'd use Unity's profiler to see what is the bottleneck, and if your collision logic is indeed the culprit, find a more efficient way to implement it.
Reply


Messages In This Thread
Ropes Lagging - by Gauri7 - 13-07-2022, 12:51 PM
RE: Ropes Lagging - by josemendez - 13-07-2022, 01:55 PM
RE: Ropes Lagging - by Gauri7 - 13-07-2022, 02:25 PM
RE: Ropes Lagging - by josemendez - 13-07-2022, 03:11 PM