Projectile hitmarker

Anyone has idea how can I make a hit marker for projectile? Basically when I hit an enemy with bullet (projectile) I want hit marker to appear on top of my crosshair.
I know how to do it for hit scan, but can’t figure our exactly how to do it for projectile.

Be sure to set up the instigator of the projectile (which is the controller that owns your weapon) when you spawn it.
Then on the Event Any Damage, which is called on the Actor which received said damage, you can get the “Instigated by” to access the controller who instigated the damage to that actor.

Then you can cast to your controller class and call a hitmarker function which will show the little cross on your UI.

The idea is to know who fired that bullet so that when the bullet hits a player it knows who to tell. When you spawn the projectile there’s an option to pass an instigator, this basically means who made this happen, there you can pass the player who fired that projectile, when the projectile hits something Get Instigator Cast to whatever CharacterClass or PlayerControllerClass if you passed a player controlled then call a function that shows the hit marker.

Hope this made sense.

Basically I need to do these right?

And how can I set that it shows widget (hit marker) when I hit someone? Ok I know I should “Create a widget” and add it to view port. but how can I set Owning player?

My comment above!

With print string I checked, that “Get instigator” works good. It gives me back right value. Only Idk how to get a widget.

Anyone? Please?

Hi,

On the begin play of your controller you need to create your HUD widget and cache it in a variable. This can be done with the node CreateWidget and selecting your widget in the class variable. Then you would save the blue output reference on a variable.

Next, you need to create in your widget an animation that will play with the alpha (opacity) of the hitmarker over time (see documentation of how to make animations on UMG). Then you need one function or event on your widget blueprint that will play that animation.

Next you need to create one event on your controller named: “DisplayUMGHitmarker” or similar. This event will call the widget function you created. In order to call it you need to use the variable we setted previously when we created the widget.

Then on event any damage you can cast to the controller and call the event you created on the controller.

vorixo

If I set instigator as object it gives me an error, that pawn will always fail.

In your character BP when using the create widget node, make sure to save that widget in a variable by right clicking on the result of the node and select promote to variable. Right click somewhere in your Character BP and create a custom event let’s call it “ShowMarker” now in your projectile blueprint when hitting someone get Instigator then cast to your character class, and call the ShowMarker event. In the ShowMarker get the widget you saved and show the marker.

What do you mean, do you care to elaborate? Done that setup several times already on different projects.

Can you please give me an example? O can’t make it work. Object is biggest issue for me. Can’t figure out right one from what I need to cast.

What I’m doing wrong here?

It’'s giving me an error.

Make the ServerHitMarker event Run on owning client

It works. Thank you!!!