gkjohnson/three-mesh-bvh

Trouble with replicating character movement

Sceat opened this issue · 2 comments

This isn't a bug but a request for knowledge

I've been trying to understand and reproduce the player movement example but I have trouble with it even by almost being a 1:1 copy with different variable instanciation. There is 2 parts of the dungeon model which makes my capsule thinks it's on ground and thus very slowly move down instead of instantly moving down

On my side the capsule float above the stairs, like if the green visualizer line acted as "jelly", and slowly move down
as the gravity velocity of onground=true is applied

image

Your example, capsule has no problems with the stairs

image

I run the demo at the same time on a different tab to compare and everything works fine, i've been trying since a day to fix it without success, pasting the code is a bit outside the scope as it's basically a copy but with creation of object instead of reusing those tempVar

I'm looking for any ideas on what would theoretically cause this, not really looking for a solution as I simply try to learn

I think it comes from const triPoint = tempVector; because the tri.closestPointToSegment is using this vector and modifying it, this is quite confusing and as I was passing the capsule position directly instead of this temp vector, it's causing discrepancies, the fact that vectors and matrix are reused for different purposes makes it hard ton comprehend

Ah well, explaining the issue actually helps solving it 🤡, doing this removes the problem

- const triPoint = collider.position
+ const triPoint = new Vector3().copy(collider.position)