I’m having some trouble getting collision events to trigger for a mechanical actor I have in my scene that uses a skeletal mesh, and physics asset. My projectile passes right through them without getting the OnHit event.
Can someone please explain to me what are the proper settings for the Skeletal Mesh:
Physics:
Enable Per Poly Collision YES
Physics Asset MyActor_Physics
Settings for MyActor_Physics:
root bone
Physics
Mass in Kg YES
Mass 100
Enable Gravity NO
Physics Type Default
Collision
Simulation Generates Hit Events YES
Collision Response ENABLED
bone2
<same as above>
bone3
<same as above>
Then I apply Asset → Apply PhysMat
In my BP class that inherits my APawn code, I set the following:
DefaultSceneRoot
Physics
Should Update Physics Volume NO
SkeletalMesh
Physics
Simulate Physics YES
Enable Gravity NO
Constraints NONE
Start Awake YES
Physics Asset Override NONE
Should Update Physics Volume NO
Collision
Simulation Generates Hit Events YES
Generate Overlap Events YES
Collision Presets BlockAll
Thank you Pumpy Bird. I should have included that too.
The projectile is a static mesh and I can break in Visual Studio debugger on the OnHit event, which shows that I am hitting other parts of the scene but not my actor.
Static Mesh settings are:
Import Settings
Auto Generate Collision YES
Collision
Customized Collision NO
mrooney, I suspect the projectile may be going a little fast, and I can certainly turn on CCD. Is that for the projectile itself?
Forgive me, but I’m mid stream in making changes to my code. Previously I followed along with this walkthrough:
taking parts that were related to me. One area I wanted to get away from is the inclusion and construction of the collision component. Is that possible?
Is it possible to assign the collision component in the BP editor, and search for it in code? I’m looking for a way to add my own event handler to the collision component without being tied to a specific type of collision component:
I’ve never actually made a component in code, opting mostly for blueprints, but I can tell that your collision component doesn’t seem to have a collision profile, which could make it not want to collide with anything.
Personally I’d make it in blueprint just because it’s so much easier to make sure all the right checkboxes are ticked. You can definitely bind your C++ callback to the OnComponent hit in BP. Just make your OnHit function blueprint callable and then use the On Component Hit Function on the collision component to call your function.