stride3d / stride

Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
https://stride3d.net
MIT License
6.65k stars 957 forks source link

fix: Unable to Change CharacterComponent's collider shape properties without causing crash #2428

Closed dloe closed 2 months ago

dloe commented 2 months ago

PR Details

Assigning a new ColliderShape into CharacterComponent and running ComposeShape() causes a UAF related exception to be thrown. Related to an issue with the KinematicCharacter reference inside of the discreteDynamicWorld in the Simulation object.

Solution would be to add additional setup to a overridden ComposeShape() method inside CharacterComponent. This setup would include the complete removal, reconstruction and reintegration of the KinematicCharacterController to the Simulation. Also added an additional function to try and maintain various physics properties onto the KinematicCharacter such as Gravity, Fallspeed, etc.

Related Issue

https://github.com/stride3d/stride/issues/2005

Types of changes

Checklist

Eideren commented 2 months ago

Thanks !