• 3D
  • Have anyone made a 3D fighting game?

I recently encountered a problem about how to attach collision shape to bones so they can be moved and collision detected with the animation. Full discussion is in this thread: https://godotforums.org/discussion/26556/physicsbone-of-kineticbody-has-no-effect-in-collision#latest.

I think a 3D fighting game probably need to solve this problem. Think of the character has some fighting animations. To check the animation actually hit the enemy and don't cause obvious overlap with enemy's model, I think there should be some PhysicsNode attach to player's fists and feet, and move together with bone animation. My current attempts 1) player as KinematicBody, add PhysicalBone as BoneAttachment to fist/head bones as child of the the Skeleton. 2) player as KinematicBody, click "Create Physical Skeleton" on Skeleton, godot generate physics bones for every bone. Adjust fist/head's PhysicsBone's CollisionShape to be a little larger than fist/head. 3) with 1) or 2), but change PhysicsBone to something else, I tried KinematicBody and RigidBody.

All Results: no collision as if head/fist were air.

So I'd like to discuss: Has any one attempted to make 3D fighting that solves this problem? How do you solve it? Sorry I couldn't find any open source examples of this online. If you are interested to give a try with some code, you can clone this repo: https://github.com/GDQuest/godot-3d-mannequin. If you run the player against the wall, the head would inject into the wall. The goal is to avoid that.

Thank you!

AFAIK, fighting games use hitboxes, not physics, for the fighting collision. I believe you could do this in Godot with Areas, then check Area Entered or Overlapping, and you can set collision mask/layers so that the players only collide with each other (and not the floor, themselves, etc.).

Thanks for @cybereality 's hint! I took the idea from your replies and finally make it! For future comers that interested to this topic, you can view this branch of this fork: https://github.com/ailisp/godot-3d-mannequin/tree/fight Basically the upstream repo has a human, it can run but head would overlap with the wall (no collision is detected there). My branch improvement:

Head doesn't overlap with the wall, and it's for every animation, head collision moves together with the head bone
Add an attack, by pressing "J", and if the right hand fist hit the wall, player will be bounce back

For a high level overview on how this is made:

Add bone attachment to Skeleton, select bone attachment property to attach to head/hand bone, this will move attached objects as animation moves
Add Area as sub node of bone attachment, add CollisionShape to Area that roughly match head and fist's shape
Connect Area enter body / leave body to set / clear a flag variable to indicate collision happening
In physics process check that flag variable and if collide, move_and_slide player accordingly

Some caveat i run into:

must set Collision Layer/Mask of Player to not collide with player, because area is attached to player body, if not set it's always considered as colliding
must set physics fps to 120, otherwise head area still overlap with wall than bounce back.

Okay that sounds about right. Glad to have helped.

4 days later

@jdoohen52 I don't mean to nitpick in any way, but a lot of your answer is hard to read because it's formatted as code by accident, so it would be cool if you fixed that. Kudos to you for working on this, btw, I know melee games are really hard to code. =)