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"

Problem with access to actor variables without casting.


There is a problem with access to the variables of the actor (Blueprints).

For example:

The actors are created after the start of the level.

At one level we are have 50 actors (bots) of different types (orcs, goblins, gnomes, dragons, etc.).

All of them have a variable "HP".

How can get access to variable "HP" or other component of a particular actor without casting?

Product Version: UE 4.16
more ▼

asked Oct 12 '17 at 06:43 AM in Blueprint Scripting

avatar image

Alexander S.
8 1 2

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

1 answer: sort voted first

Parent them to a 'NPC' blueprint that has a 'hp' variable. That way you can just cast to a 'npc' bp without worrying about which specific actor is referenced.

more ▼

answered Oct 12 '17 at 09:06 AM

avatar image

164 2 3 6

avatar image Alexander S. Oct 12 '17 at 10:57 AM

Thank you Salm. This is really good idea. However, maybe there are other ways to solve, more universal without hierarchy of actors? It is interesting to hear other possible solutions.

avatar image salm Oct 12 '17 at 01:38 PM

Well, you could also use an interface. Add a 'NPC' interface with a GetHP function, but then you'd have to implement the function to each BP. Just in case you missed it, have you checked out ContentExamples? I'm thinking of the PowerUp pickups and child variations.

You could also try to put a map linking actors->HpValues in your gameinstance, but I haven't tried that.

avatar image Alexander S. Oct 12 '17 at 05:10 PM

Now I'm use array's in GameInstance to save all NPC's, Buildings and other interactive actor's on level with self references and other data. When i need interact with someone of them i just check selected with equal actor from array. But this metod not flexible and not so fast.

(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