Generating Hit Event from Raycast?

I have:

  • Raycast gun (no actual projectile) on character blueprint.
  • A shield BP (mesh and collider) with some impact effects on the shield material that needs the collision location to work.

Turning on collisions on my shield and/or sphere collider is doing nothing. No hits are registered from gun. I’ve since learned that raycasts don’t initiate a hit event on the hit actor.

So, how would I do this - get my shield to recognize the raycast hit?

Hi @Rhadley
i would simply manually , From the raycast gun , fire a custom event in the shield, to do what you need.

  • in the gun

  • in the shield:

image

You don’t need to do anything with the damage. All actors have it, why not use it.


  • Or, ideally, add your own interface and pass the Hit Result struct.

It can be done with a Custom Event but that will be clunky. You’ll need to start casting all over the place. I’d avoid it.

1 Like

I started playing with the anydamage event, shield side, but how would I pull the impact point from that?

As above, if you need specific data passed, you make your own interface.

  • the interface:

image

  • the weapon blueprint:

  • the (shield or any other) actor that implements said interface:


Think of an Interface as of a collection of functions that do nothing on their own. Granting an actor access to that interface allows it to implement functionality individually.

Whenever the raycast (linetrace) hits, we call the Generic Hit. A Tree actor will implement the function differently than a Shield actor.

And if you Generic Hit an actor that does not implement that interface… nothing happens, which is great.


Some good reading here if you’re into studying docs:

Okay, I’m with you. For some reason I thought the interface was a separate suggestion from the comment above it. I shall try it, thank you for the direction.

1 Like