So I've searched and searched... maybe I'm just passing the answer over and over again. I'm just trying to catch when the character hits a wall, that's it.
I've done this in blueprints, but trying to get it over to c++ is just not working, so I was hoping someone could explain how I can get the hit result when running into a wall in c++.
I have the source, but surely this can be done in a c++ project without having to go into the actor class? I feel dumb asking such a simple question, but at this point I'm just wasting my time by not asking.
Capsule, Character, whatever, just want to catch collision. I just want to be able to run into a wall and output a debug message saying its hitting the wall.
There are two ways of detecting collision for an actor. Either you use the built in Hit function or you bind a function to a UPrimitiveComponent's OnComponentHit multicast delegate.
Approach #1: Override
and implement your logic there. Don't forget to call Super::NotifyHit!
Say you have a reference to a specific primitive component that supports collision like a static mesh or a capsule collider. You can add a custom UFUNCTION to its OnComponentHit delegate like this:
Don't forget to remove your function from the delegate for example in EndPlay by calling RemoveDynamic instead of AddDynamic. It uses the same signature.
Sorry for the weird layout but the code sample block is not that useful in terms of easy to read layout.
Follow this question
Once you sign in you will be able to subscribe for any updates here