Download

Wall Collision or Hit Detection

Howdy,

I’d like to find out how to get collision events for a Character/Pawn with a wall. I looked in character, but I didn’t find it.

By wall I mean either a static mesh or BSP.

Thanks,
-R

You should just be able to override the ReceiveHit virtual function.

Thanks James,

Which class contains the definition for ReceiveHit?

ReceiveHit is defined in Actor. You can have a look at the ATP_FlyingPawn class in the Flying template for an example. You can also use the OnComponentHit delegate on a component, if you want this to fire for a specific component within your Actor. Have a look at the ATP_FirstPersonProjectile class in the first person template for an example of that.

Perfect. Just what I needed. Thanks!

I have a sort of addendum to my question: Is there a built in way to test for collisions actively? i.e. User presses button, then I check for collisions at that time, and do something based on that.

better first check if collision and then if button is pressed

That’s the question, though. How do I check for collision on demand? I’ve been attempting to get OnActorBeginOverlap to work, but that doesn’t seem to work.

You can use ‘line trace by channel’ to check for objects in front of the character and do Things based on the hit results, such as hit Location or if the trace hit an object or not and many more. Not sure if that’s what you wanted, but it might help you.