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 to check if the actor I'm looking at has tag?


I'm building a third person shooter and I'm trying to make the character shoot at the enemy only when aiming at it. Up to now, when in aiming mode, the character's aim offset is used to point where the camera is pointing, and an IsAiming boolean is used to prevent the player from shooting if not aiming, so bullets don't get fired everywhere if the weapon is not pointing "downrange".

My next step is to make the player only fire at enemies (I"m trying an auto fire system for mobile controls testing). I would like to trace from the camera and check if the first hit object is an enemy. I'm currently using an "IsEnemy" boolean on BeginPlay to differentiate characters that are not controlled, but I'm open to suggestions. I know about how to get the tag of object under cursor, but can't seem to find a way of doing it properly with the camera. The end goal is to trace while the player is aiming (from the active camera, also have a sniper camera) and if the actor that I point to is an enemy, call the Fire function.

It would be great if the solution was actually a line trace, because I could set the limit to be a variable "weapon range".

I'm pretty sure the answer is under my nose!

Thanks everyone.

Product Version: UE 4.22
more ▼

asked Aug 13 '19 at 07:59 PM in Blueprint Scripting

avatar image

60 4 10 17

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

1 answer: sort voted first

Hello Fred,

If you would like to check the tag, simply run a line trace and upon success get hit actor and use node Actor Has Tag. If actor has the right tag - run your Fire function.

Let me know if you need help setting this up.

more ▼

answered Aug 13 '19 at 08:27 PM

avatar image

805 4 5 7

avatar image FredPoissant 4 days ago

Hi Don,

Yes this is exactly what I was looking for! I had'nt used that in a while and was struggling to get the right node.

Thank you very much!

avatar image DonBusso 4 days ago

You're very welcome. Always happy to help. :)

Just on a side note, you could also use Cast to or Get Class for the actor you hit with line trace and take action based on that. Of course it all depends on your needs and design.

(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