upbge icon indicating copy to clipboard operation
upbge copied to clipboard

Character Collision Latching

Open IcyChills opened this issue 2 years ago • 10 comments

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.

IcyChills avatar Jan 29 '22 01:01 IcyChills

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 avatar Jan 29 '22 08:01 youle31

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?

youle31 avatar Jan 29 '22 09:01 youle31

@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

IcyChills avatar Jan 29 '22 15:01 IcyChills

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:

  • I've not Tristan's brain.
  • It can create a mismatch between upbge and blender in physics simulations behaviours.
  • When/if Bullet library is updated, it can be a pain to apply again the patches taking into account new Bullet changes.

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.

youle31 avatar Jan 29 '22 16:01 youle31

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 avatar Jan 29 '22 16:01 IcyChills

@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.

IcyChills avatar Jan 30 '22 19:01 IcyChills

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

make update

BluePrintRandom avatar Jan 30 '22 21:01 BluePrintRandom

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

IcyChills avatar Jan 30 '22 22:01 IcyChills

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.

IcyChills avatar Jan 30 '22 23:01 IcyChills

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

BluePrintRandom avatar Jan 30 '22 23:01 BluePrintRandom