Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How do you make a damage marker for an fps?

I am making an fps game. How would i make a thing that when you are shot it has an arrow on your screen that shows where you've been shot from

Product Version: UE 4.22
more ▼

asked May 18 '19 at 11:23 PM in Using UE4

avatar image

3 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I've not implemented a feature like this before, but this is how I would approach it.

Set up a widget, if you haven't already. In the middle of that widget, you can add an image or material. When your character gets shot, keep a record of the direction they were shot from as a rotation, probably in world space. You can then add some logic into the widget graph to take that rotation and convert it into an angle. Something like finding the difference between your characters rotation and the rotation of the shot, where if you are facing directly towards the shot it returns a 0 angle and if you are facing away, it returns 180. Makes sense.

You can then use that angle to rotate the image you placed earlier. Widget components have render transform information which includes an axis of rotation. If your logic is correct, you can rotate an image (most likely of an arrow) to point in the direction your character was shot from.

I know there are more complex ways this can be done to allow for multiple arrows, for example, but hopefully this can at least get you started. Hope this helps.

alt text

more ▼

answered May 19 '19 at 01:28 AM

avatar image

33 1 4

avatar image rubiksmaster02 May 19 '19 at 01:48 AM

can you put that in simpler terms XD, im VERY new to ue4, i got everything up to keep a record

avatar image OneViGOR May 19 '19 at 02:20 AM

I can try, but short of programming the entire mechanic I can't show you the exact logic you'll need to make this work.

Then your character gets shot, I would imagine this means I function on your character is called to make them take damage. You can extend this function to also keep a record of the angle of the shot. This could be done by getting the direction of the bullet when it hit, or by getting a look rotation to face the character/turret/other that shot you (using the Find Look at Rotation node).

Once you have this, you could break up the rotation to find the yaw (because pitch and roll likely won't matter) and get the difference between this value and the yaw rotation of the character. This is the angle the arrow on your damage marker should be made to point.

You can pass this value to a widget and store it however you like, but once it's there you can set the render angle of an image on your HUD (the arrow) to the angle you calculated.

This won't be perfect functionality right out of the box, but it should get you on the right track.

I'm writing this on the assumption that you know the basics of UE4, like how to pass variables between blueprints and how to make widgets. If not, that's fine - we all started somewhere - but this isn't the place to explain them. I'd suggest looking up some documentation or tutorials to help you out. You'll need this level of knowledge at least in order to do anything even remotely complex in UE4 and a lot of it is pretty straightforward.

Best of luck.

avatar image rubiksmaster02 May 19 '19 at 02:25 AM

i only want it for any damage, i havent programmed bullets or guns or anything only an object that hurts you, but i want to make the damage marker still point in that direction

avatar image OneViGOR May 19 '19 at 02:28 AM

Then you can use the look rotation I mentioned to point towards the actor that caused the damage. Everything else should still work the same way.

avatar image rubiksmaster02 May 19 '19 at 02:32 AM

OOOOOOO that makes sense i thought you mean track the rotation that the player attacked you is facing

avatar image rubiksmaster02 May 19 '19 at 02:45 AM

nvm i thought i would be able to make the first part but i have no idea

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question