#KinematicCharacterDeferredImpulse easily breakable

1 messages · Page 1 of 1 (latest)

steel schooner
#

I got this error from KinematicCharacterDeferredImpulsesSystem, and as you can see on the right side of the screenshot, the entity in the existing KinematicCharacterDeferredImpulse element is not valid.

I'm not touching the buffer directly, so I can't make sure added entities are valid (At least I don't know how, other than running a system before the ImpulsesSystem, that validates each element). I don't know if one of the KinematicCharacterUtil functions is affecting it though.
This happened when a projectile, which is destroyed after hit, hit the character.

So, what options are there? Would it be too expensive to just validate the entity with TryGetComponent? Is there a way to avoid certain entities to interact with this systems?

worthy herald
#

Do you have an ECB system or some main thread EntityManager code updating in the KinematicCharacterPhysicsUpdateGroup? If that's the case, you could simply move those to update after KinematicCharacterPhysicsUpdateGroup

Normally, the character update happens in KinematicCharacterPhysicsUpdateGroup (this is where defferred impulses are added) and this is directly followed by the KinematicCharacterDeferredImpulsesSystem update. If no structural changes happen between the two, then the added entities should be valid. If they are not, then this would definitely be a bug

A HasComponent check could be added in the next version though, as an additional safety. I don't think it would have much of a performance impact in the common case

steel schooner
#

Which one is the system in charge of adding the impulses?

worthy herald
#

adding impulses happens in the various update steps called in the character Aspect's PhysicsUpdate, which happens in the First/ThirdPersonCharacterPhysicsUpdateSystem, which by default is in the KinematicCharacterPhysicsUpdateGroup

Actually, looking at the code, the issue could also happen if there are structural changes between when the physics world is built (in PhysicsInitializeGroup), and when the KinematicCharacterDeferredImpulsesSystem updates

#

I'm convinced it's worth adding the HasComponent check in the KinematicCharacterDeferredImpulsesSystem at this point, but I'm theorizing about potential fixes in the meantime

steel schooner
worthy herald
#

There are no structural changes made by the package