How would I perform collision detection on an animated skinned mesh?

I created a skinned mesh and animated it so that it extends out to slap a player.

I used SpatialQuery for the hit detection and if it hits something, it should print out the hitPart’s name.

Here’s what’s happening:

In the video, the skinned mesh collides with my character but doesn’t actually register it as a hit.

Here is the script:
image

I’m assuming that despite the animation moving/extended the skinned mesh, the collision radius will stay the same at its original default spot.

HitDetectionPicture_1
HitDetectionPicture_2

Is there any way to make it so that animated skinned meshes also register hit detection when playing an animation?

You’d be right. Bones are purely visual. If a hitbox is important you could always just use parts and exclusively skin the area between joints. In this case I can see that your rig deforms as well, though, so it might be better to just use a fake hitbox when it extends.

I’d put an attachment where I want the hitbox to start, then use the very last bone in the “head” of your rig as an end position for your rig. Then I’d spawn in a part, and each frame I’d move it to be in between both the attachment and the last bone. Finally I’d resize the part according to the magnitude in between both the attachment’s position and last bone’s position.

Something a bit like this, green dot being the attachment and red line being the last bone in your model.
Screen Shot 2022-10-13 at 1.48.10 AM

1 Like

Hello thank you for your reply but there is a problem.

The bones don’t actually update Position nor does it update its WorldPosition when the deform animation is playing. How would I do the position-updating and size-magnitude with the hitbox part if the Bones’ themselves dont even update in Positions/WorldPositions in the first place?

1 Like

Or you can cast a ray when it’s about to damage anything on its path.

9960aa6480a2fb3b33f01a3552b390a147d8ec27

1 Like

I suppose Animation Markers are useful for this
(I’ll give it a try!)

You would use the CFrame of the bone rather than the position of it. I’m pretty sure that’d work since one of my friends has managed to get hair physics working by manually setting the cframe of bones.

If it’s not supposed to jostle the player but instead just register a hit, then yeah a raycast would work.

I figured it out!

Firstly, I used TweenService to tween the bones’ Orientation and Position to replicate the animation. (This will cause the bones’ positions to update since the tween is manually moving it.)

Then I continuously fired a ray from a StartPoint (Attachment) to one of the moving bones’ WorldPosition. If ray hits a player, then deal damage.

Here is the script:

Here is the result:

Here is the visualization:


PictureOne
Picture2

8 Likes