UCC Bug report

peetlepapers

New member
I am trying to report a bug with ultimate character controller but am for some reason unable to post on that discussion page despite entering my invoice. I came here to try to contribute to the project but the barriers to entry are quite severe.. maybe the forums are not the place for such discussion? if there is another place for this please advise.

I have been experiencing a significant lag spike when quickly swapping between weapons, and lots of GC alloc. I found that a large portion of the GC alloc was coming from Spring.cs, which by default creates an array m_SoftForceFrames of 120 Vector3's, and FirstPersonPerspectiveItem contains multiple of these. It seems that despite pooling the CharacterItem, the Springs are not being pooled due to their exposure to the StateSystem, causing new Spring instances to be created when the CharacterItem is initialized. With 4 Springs in FirstPersonPerspectiveItem this results in ~5kb of alloc.
I addressed this in a hacky way with a pool of Vector3[] with array length as the key (m_MaxSoftForceFrames does not change regularly so this seems to work fine)

Another big alloc was coming from AnimationEventTrigger's RegisterSlotEvent where string.Format is called to register events for specific slot events. I addressed this similarly by pooling event name & slot id string combinations.

This removed around half of the gc alloc, there is still ~10kb happening when swapping back and forth between items that I cannot determine the source of, it seems to be coming from the State system.
 
Back
Top