stride3d / stride3d/stride

Thin collider shape passes through HeightfieldColliderShape

Open
#734 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Physics bug priority-Medium work-estimate-M
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: GitHub

Version: master (4.0.0.1-beta03)

Platform(s): Windows

Describe the bug
Thin collider shape passes through HeightfieldColliderShape sometimes.
Even CCD can't seem to fix it.

To Reproduce

  1. Create new project from TopDownRPG sample.

  2. Remove the Platform folder in the MainScene.

  3. Add new entity as Ground.

  4. Add StaticColliderComponent to the Ground entity.
    Colliderion group: CustomFilter1

  5. Add Heightfield to the Collider Shapes.
    Source: Float

  6. Add CountScript to the Ground entity.

    public class CountScript : AsyncScript
    {
        public class TriggerScript : AsyncScript
        {
            public int Count = 0;
            public override async Task Execute()
            {
                var trigger = new StaticColliderComponent
                {
                    ProcessCollisions = true,
                    IsTrigger = true,
                    CollisionGroup = CollisionFilterGroups.DefaultFilter,
                };

                trigger.ColliderShapes.Add(new BoxColliderShapeDesc
                {
                    Size = new Vector3(64, 10, 64),
                    LocalOffset = new Vector3(0, -8, 0),
                });

                Entity.Add(trigger);

                while (Game.IsRunning)
                {
                    await trigger.NewCollision();
                    Count++;
                }
            }
        }

        public override async Task Execute()
        {
            var triggerScript = new TriggerScript();
            Entity.Add(triggerScript);

            while(Game.IsRunning)
            {
                await Script.NextFrame();

                DebugText.Print($"Count : { triggerScript.Count }", new Int2(10));
            }
        }
    }
  1. Remove Trigger, Rigidbody and LootCoinScript from CoinGold entity of LootGoldCoin prefab asset.

  2. Set Transform.Position.Z of Camera entity to 20.

  3. Run the game and punch LootBoxes.

Some coins pass through the Heightfield.

Expected behavior
All coins don't pass through the Heightfield.

Screenshots

Log and callstacks

Additional context
#494(Additional context)

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

Reproduce the issue in the TopDownRPG sample using the MainScene changes, CountScript, LootGoldCoin prefab, and HeightfieldColliderShape described in the report. Start by isolating the collision behavior between the thin coin collider and the heightfield, including with CCD enabled. Done means repeated runs show that no coins pass through the HeightfieldColliderShape.

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.