Probblems with my hit scan Help

hi guys im new to unreal and im having problems with my hitscan / linetrace based shotting, im trying to implement a hitbox system so that when i shot the head it deals more dmg than on the body, but im having some troubles, firts i used hit component saying the component i wanted to hit so i create a static mesh and atached it to the head of the character but it didnt work then i used bone name and did this but still not working, does anyone know how can i do this please?

If I put a sphere collision in the character and set it to block all

image

I can trace to it, and find it with ‘hit component’

hit

image

1 Like

While the above may be enough for a headshot, consider this approach as well:

It’s using bones to handle hits. On top of that, I’d look into the Damage Class - it can process the Hit struct from the trace (hit scan) and apply modified damage.

2 Likes
  1. Can you edit/clarify which Trace type you use (to detect a Character Component part)?
    E.g. Trace for Objects, or Channel, or?
  2. And can you show the Collision settings for the Sphere collision/component (in CharBP). E.g. what is its Collision type?
  3. And does “Simulation Generates Hits” need to be checked on this component? Ty

(Im trying to get the hit Bones and/or Child Mesh Components in my CharBP. Thus I want to know which Trace type works for Char Component types of things, and for Bones (SK mesh). Im not sure if Char Capsule is blocking the trace from hitting SK Bones - according to my Trace setup?

I randomly get (Print return) Bone name as “None,” during a multi hit arc that should have penetrated SK Bone mesh. Yet sometimes Bone name does detect correctly.)

Long time ago, but I’m pretty sure it was a stand visibility line trace, and the sphere was ‘block all’.

1 Like

Ty. So for Visibility type, Player Capsule is considered invisible, and thus the Trace goes to SK mesh, correct?

1 Like

Yes.

Ty, but I tried Visibility trace; it didnt work to detect Bones or even Hit character :frowning: (code in blue and pink box).
(While my prior pic worked to detect Hit character and sometimes Hit bone name: Trace by Object type.)

Should I start a new thread?

Yes, maybe start a new thread. Did you see Everynone’s post just up there, about finding bones?

1 Like

Yes, I looked before posting here. But I dont understand how he “Finds” the Hit Bones.
Can you quote which post/pic has his Hit Bones? Ty.
I see the Find > Map. But it is connected to [Event Point Damage] (and not the Out Hit from Trace Channel). So I dont understand where [Event Point Damage] comes from.

  1. And I see he setup the “Physical” Bone map… are those bone names dependent on Physics Asset > Components of the same bone name?
    (Per another thread, I checked my Physics Asset > it had some holes > I made volumes larger. But it also had Spine1 deleted. And filled it with a bigger Pelvis. Not sure if that matters related to actual Bone Hit-detection?)
1 Like

@Everynone, what is your ‘bone hit’ secret? :slight_smile:

It’s a Map association, Name + Enumerator, it’s in the thread. The entire project is attached.

1 Like

I would highly recommend using the phys asset or bone on the skeletal mesh itself.

This is such a common thread that I’ll be pushing a tutorial on the learning center covering this in detail… soon™

Anyway, you need a trace channel to ignore the capsule component so it can hit the skeletal mesh. A new trace response is needed. (proj settings → engine → collision). Call it Hitscan (block, default).


Update your characters capsule component collision. Custom… ignore “Hitscan” trace.


Skeletal Mesh Component.
Enable “Return Material on Move”… Collision → Advanced… near the bottom.


Use the Hitscan channel for your trace. Now your traces should hit the pawns skeletal mesh. From hit result you can now use “Hit Bone” to determine what part of the body was hit.

Trimming the options you can create a few new physical materials.
PM_Head, PM_Neck, PM_Chest, PM_Torso, PM_Arm, PM_Leg, PM_Hand, PM_Foot

Open your Phys Asset for your character. For each collision hull assign a physical material.


Make sure you tick “Simulation generates hit events”.

You now have a reduced list of potential hit areas. From nn bones to 8.

1 Like

Thanks so much for the setup images.
Questions:

  1. Is there anything I need to be aware of [with Physics Mat hit detection] when I’m using Modular mesh setup?
    UE4 modular meshes
  • I.e. when I use the [Set Master Pose Component Function] - this sets all child meshes to use the same Animation (and I think Physics Asset), that the main Character mesh (Main body) is using.
  • Thus does this mean that if Main body mesh and Chest armor mesh are both hit at “Spine_03” bone (or PM_Chest) - in the same sweep (both share the same bone area) - then only 1 bone-hit will register, instead of counting Spine_03/PM_Chest as hit twice, correct?
  1. What if I want the opposite = detect multi hits on all modular parts sharing the same bone/physics area?:
  • If player is wearing Chest armor and gets hit there, I want to register two hits on PM_Chest (1 because the Main body mesh was hit, and 1 because the Chest armor mesh was hit - while both share the same PAT, I think).

  • How would I do that while using [Set Master Pose Component Function]? - (which I think takes away the PAT of the Chest Armor mesh, and replaces it with whatever the Main body mesh is set to use? Or maybe it nulls the PAT that Chest Armor mesh has, so that only 1 combined mesh PAT is used at a time?)

  • And if I’m wrong above, then for multi mesh hit, do I need to set a PAT for every modular mesh part?
    ** (For some FBX meshes, I have been importing without creating a PAT for that body part, since some are so similar to the main body. But for smaller parts like boots, I am unsure if I need to setup a smaller PAT in Editor, that doesnt have the PM_Chest assigned?
    ** Or can I merely assign the Main Body PAT (already setup with full body PMs), on every small mesh part after import - thus since boots have no geometry at the chest, then PM_Chest would never be triggered anyways?)

Thank you :slight_smile:

Master Pose should use the base skeleton phys asset. Each modular component should be using the same skeleton. I know it does with Mesh Merge.


For armor/Helmet etc gear you’ll do damage calculations based on whether armor is equipped or not. You need to keep track of that from inventory or other.

So say you get hit in PM_Chest or PM_Torso. You’d calculate full damage as if no armor was applied. Then, do a look up to check if the character has armor equipped. If so do your base damage reduction. Armor takes n% of damage… apply the remainder.

Same for helmet.

1 Like

Thanks a lot for your time and images. Please ping me when you upload the full guide or anything related :slight_smile: