stride3d / stride3d/stride

Can't change CharacterComponent's collider shape properties

Open
#2,005 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: Official Release

Version: 4.1.0.1948

Platform(s): Windows

Describe the bug

Assigning a new ColliderShape into CharacterComponent in code (when game is running) and then calling CharacterComponent.ComposeShape(); causes the application to crash.

To Reproduce

  1. Create basic character with CharacterComponent.
  2. Assign capsule collider shape using Stride Studio.
  3. Assign script which perform this code (ex. when key is pressed)

characterComponent.ColliderShapes[0] = new CapsuleColliderShapeDesc()
{
Length = 0.6f,
LocalOffset = new Vector3(0.0f, 0.70f, 0.0f),
Orientation = ShapeOrientation.UpY, Radius = 0.4f
};

characterPhysics.ComposeShape();

  1. This will caus the application to crash.

Expected behavior
CharacterComponent starts to use new collider shape with new property values...

Log and callstacks

  • I can see this in Windows Application Events:
    dDrive.Windows.exe
    1.0.0.0
    64e81669
    libbulletc.DLL
    0.0.0.0
    5ccee150
    c0000409
    0000000000166069
    3b48
    01da0915ea6c6440
    C:.....\Bin\Windows\Debug\win-x64\dDrive.Windows.exe
    C:.....\Bin\Windows\Debug\win-x64\libbulletc.DLL
    6959c4f8-c585-472a-967f-89ccbed61439

Additional context

  • I need to change collider shape because of different character poses, like crouching and so on...

  • It seems trying to use Dispose() on any type of collider shape causes it. ColliderShape.Dispose(); is called inside Stride.Engine.PhysicsComponent.ComposeShape() method.

  • @Manio143 tip from discord:

I imagine we don't properly remove some reference after the dispose frees the native handle to the bullet collider and we still attempt to use it afterwards which is what causes the crash.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CharacterComponent.ComposeShape() and Stride.Engine.PhysicsComponent.ComposeShape(), then trace how ColliderShape.Dispose() interacts with the native libbulletc handle. Reproduce the crash using the capsule-shape reassignment steps on Windows and verify that composing the new shape no longer crashes and applies the requested collider properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.