Skip to content

Scale skin_width by PhysicsLengthUnit#898

Merged
Jondolf merged 3 commits into
mainfrom
scale-skin-width
Nov 26, 2025
Merged

Scale skin_width by PhysicsLengthUnit#898
Jondolf merged 3 commits into
mainfrom
scale-skin-width

Conversation

@Jondolf

@Jondolf Jondolf commented Nov 26, 2025

Copy link
Copy Markdown
Member

Objective

The move_and_slide_2d example sometimes gets stuck on ramps due to a skin width that is too small. This is because it's not accounting for the scale of the world.

Solution

Scale the skin_width by PhysicsLengthUnit. This appears to fix the problem.

Testing

Ran the move_and_slide_2d example.

@Jondolf Jondolf added D-Trivial Nice and straightforward! A great choice to get started with Avian A-Character-Controller Relates to character controllers C-Refinement Improves quality or results in some way, without fixing a clear bug or adding new functionality labels Nov 26, 2025

@janhohenheim janhohenheim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentionally not scaled here?

config.skin_width * 2.0,

@janhohenheim

Copy link
Copy Markdown
Member

Maybe add a note for future us to always scale the input by the length unit :)

fn pull_back(hit: ShapeHitData, dir: Dir, skin_width: Scalar) -> Scalar {

@Jondolf

Jondolf commented Nov 26, 2025

Copy link
Copy Markdown
Member Author

Is it intentionally not scaled here?

It's passed to intersections, which scales the given prediction distance. Though it is maybe a bit confusing, perhaps we shouldn't scale any method args and only scale the skin_width stored in the config

@janhohenheim

Copy link
Copy Markdown
Member

Can we add a note here that the inner called functions perform the scaling? Otherwise it looks like we missed it and we might PR it in accidentally in the future

@Jondolf Jondolf merged commit d72c48b into main Nov 26, 2025
6 checks passed
@Jondolf Jondolf deleted the scale-skin-width branch November 26, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Character-Controller Relates to character controllers C-Refinement Improves quality or results in some way, without fixing a clear bug or adding new functionality D-Trivial Nice and straightforward! A great choice to get started with Avian

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants