1
$\begingroup$

Note: I saw this question but that isn't what I'm looking for.

I have a basic character who has an armature and several animations. Because of the variety of his animations, a simple cube collision bound doesn't work because he'll either be wiggling outside it, or on some animations, (like crouching or crawling) there will be too much headroom that makes for unrealistic collisions.

I tried working around this by creating a low-poly outline of the character for collisions, not knowing that it didn't update in realtime.

Alas! when I experimented with the output and physics visualization on, I saw that the armature only has control over the "visual" mesh, and not the "practical" mesh.

What is a good workaround so my dude can have collisions only where his body is?

$\endgroup$

1 Answer 1

3
$\begingroup$

An ideal way, in my opinion, is to have the entire character surrounded by a bounding box which will be used to have basic collisions with map entities (examples: walls, barrels, floor). Also, we can have a separate object, your character model, that will be used to have collisions with specific entities (example: bullets, rays). Your character model will have a simple python script that will ensure that his mesh updates every tick, making accurate collision. Furthermore, since the character model is contained in the bounding box, it will constantly collide (as they should be parented), meaning that your player will instantly launch off! We can fix this by changing both objects' collision group and collision mask. The collision group identifies which group of collisions it is in, and the collision mask identifies which groups it collides with. An object's collision mask and collision group is located in the physics tab.

This way, we won't have the character model get stuck and have jittery movement when playing animations (as the collision area will change shape), and specific collisions will work as you have your character model serve for that purpose.

To update the character's mesh every tick, use the following:

import bge

def update(cont):
    own = cont.owner
    own.reinstancePhysicsMesh()

if __name__ == "__main__":
    update(bge.logic.getCurrentController())
$\endgroup$
1
  • 1
    $\begingroup$ You might want to try with low resolution cylinders disposed around your character's body parts and connected to the armature, if you weight them so as they don't deform you will not need to reinstance physic meshes (?) nor using your display model for collision. $\endgroup$
    – Yvain
    Commented Jul 17, 2016 at 4:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .