Bug: Decal Manager incorrect footprint facing

hoodust

Member
1. Third Person Controller 3.3.5
2. Unity version 6000.4.7f1, Built-In RP
3. Bug description: After some time, footprint decals spawn with seemingly random x-axis "flip" (e.g. you may get all left footprints, all right footprints, left prints from right foot or vice versa, etc.).
Footprints created from re-used GO's from the pool are likely to have the incorrect facing or "flip" due to line 127 of DecalManager.cs toggles the x-axis flip without taking into account if it was flipped the first time it was used, rather than setting it:
Code:
// Changing the local x axis will flip the footprint.
            if (decal != null && flipFootprint) {
                var localScale = decal.transform.localScale;
                localScale.x *= -1; // <--- this
                decal.transform.localScale = localScale;
            }
should instead be something like:
Code:
            var localScale = decal.transform.localScale;
            localScale.x = Mathf.Abs(localScale.x); // <-- remove any negative X axis scale
            if (flipFootprint)
            {
                localScale.x = -localScale.x;
            }
            decal.transform.localScale = localScale;
4. Steps to reproduce from a fresh project: Use a character with foot effects, preferably with noticeably asymmetric footprint texture, and walk around a surface that shows footprints for 100 steps (or however large the Decal Limit is set in DecalManager). New footsteps after that point are liable to have incorrect X scale sign based on the foot that produced them.
5. The full error message (if any): none.
 
Thank you for reporting. That's a good fix. You're right in that root cause related to the ObjectPool and reusing the prefabs. Thank you!
 
Back
Top