How can I detect when a player's character is hit by another object (read desc.)

Hey guys, I wondered if there’s any creative shortcuts that anyone can think of.

I need to detect if either a high velocity object hits a player, or the player has high velocity and hits a solid object - for ragdoll physics. My original idea was to constantly check collisions on the character and add the two velocities to get the resultant force that I can apply to the character however this might end up being expensive.

Another idea I had was to tag certain objects that could cause this effect however this could be extremely tedious and likely won’t be able to get the effect that I’m looking for, since I want any object to be able to trigger this behaviour. For example, if a character is on top of a train, and gets hit by a solid object e.g. a bridge, they would ragdoll. Seems a bit counterproductive to tag each part of the bridge at that point.

Any suggestions appreciated

You can use the .Touched function for unanchored objects and you could use WorldRoot:GetPartsInPart() to get anchored parts, you could use OverlapParams to only filter anchored parts, but you can use PartsInPart for both if you want.

Now if you take the offset in magnitude of Velocity Vector.Magnitude and try for the part the player is touching you can get the affect of it. So for .Touched you can just find the Difference in Velocity between the two objects and see if the unanchored object is fast enough

Now for the anchored part you could give the player a slightly bigger hitbox with a part, and the part reads the anchored parts “Velocity” by getting its difference in position from frame to frame, this might only work in slower-ish parts though.

Im not really great in velocity, but Im sure you could get the players character or primary part and just use a .Touched function.

Every moving object could cast rays in the direction of travel. Faster travel = longer ray. Then you can just see if it intersects with a character

1 Like