UPBGE / upbge

UPBGE, the best integrated game engine in Blender
https://upbge.org
Other
1.44k stars 181 forks source link

Character Collision Latching #1648

Open IcyChills opened 2 years ago

IcyChills commented 2 years ago

General Setup: Game Physics -> Character + Collision Bounds -> Capsule.

Result: Walking against causes collision model to latch onto a wall, allowing character to somewhat climb a wall. Jumping also sometimes causes collision to latch onto the ceiling.

Increasing margin in Collision Bounds lessens the effect however will sporadically cause the latching effect.

youle31 commented 2 years ago

Maybe related to : af13cc36c7c72d6392367964065f71ede059ef9c

test file : character.zip

gif to see the bug in the test file:

Animation

EDIT: The commit I mentionned doesn't prevent the character to be stuck on the ceiling

youle31 commented 2 years ago

What version do you use? Do you have a test file? Did you follow upbge 0.2.5 development (do you know if someone previously worked on your issue). Is my testfile showing the issue?

IcyChills commented 2 years ago

@youle31 Hi Youle.

Yes that is exactly what happens. I'm using version 0.3.

The walls are set to Triangle Mesh for collision bounds with a margin of 0.04m, increasing the margin on the walls to 1m seems to negate the latching effect, however it does cause the character collider to bounce off the wall when walking alongside the wall. Maybe some float value could pad the collision detection rays, just not sure how expensive that would be.

Test scene: https://filetransfer.io/data-package/RrKY41j8#link

youle31 commented 2 years ago

Okay. It is possible that Tristan (panzergame) fixed this issue (in old upbge versions) because he was editing directly Bullet physics library sometimes like here: 0ba989707e3404f13afbdf168531e94a15bff262

I noticed that sphere had same issue in 0.2.5 too.

Problem is that I'm personally reluctant to edit Bullet for several reasons:

If Tristan joined again the team and would like to make these changes, i'd be ok, but for now, I can leave the issue opened if someone wants to take the responsability of changing Bullet, but I don't want personally to touch to these files.

IcyChills commented 2 years ago

Thanks for the link, I'll take a look at the changes from the older version and see if it works on my fork of UPBGE. I just need to setup my build environment first.

IcyChills commented 2 years ago

@youle31 I've got Upbge 0.32 building. However I can't seem to find the link for the Win libraries for the BGE scripts and can't find it on the Mega links from the upbge site. For the time being I've copied the missing addon scripts from the 0.3 folders.

It seems the Collision code changes you linked is the same before the changes. Going to implement those changes tonight and test. Will upload the changes to my fork if the test is successful. Will try to keep compatibility with original Blender code, maybe a switch or if else between non-bge and bge during use case.

BluePrintRandom commented 2 years ago

after downloading the source go to the upbge folder and type in the command prompt there

make update

IcyChills commented 2 years ago

@BluePrintRandom Thank you. I used "cmd //c make.bat update" through Msys2. Did the trick.

IcyChills commented 2 years ago

I made the changes to the code based on Panzergame's code from 0.25, it compiled successfully and I tested it. It added more jitter to the collider when hitting other surfaces and the latching remained, so I'll be reverting back to the original code.

I'll familiarize myself with bullet physics. A few posts after reading up online refer to depth penetration, continues collision detection. and the raycasting options.

BluePrintRandom commented 2 years ago

one idea is to just use a ray and if it intersects stop velocity in that direction so the capsule can't touch

you can use the same ray to detect ledges etc with a little hitbound object at each ledge

I have used something like this in wall jump / ninja games too :D

mod = .125
start = own.worldPosition
end = own.worldPosition + (own.worldLinearVelocity * mod)
ray = own.rayCast(end,start,0,"",0,0,0)
if ray[0]:

    you hit something