x

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 get the index from an array element?

I'm making the targeting system for a turn based RPG and would like to get an element index in integer form, so I could check who's selected and stuff like that. Is it at all possible, or do I need to create an integer and manage it all the way through?

Product Version: UE 4.20
Tags:
more ▼

asked Sep 09 '18 at 09:15 PM in Blueprint Scripting

avatar image

BillyOAntiBully
1 1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

No, because TArray same as raw C++ array is using memory offset as index, making it unreliable id, if you remove element from array it will move all farther items in memory in direction of removed item. You might consider using TMap which use key to value pairing (TPair) to store items and you can use any type as index, at first it might not make sense to use integer as key type as it will work like TArray, but thing in TMap set index will be persistent or else you will change index of the item yourself

more ▼

answered Sep 09 '18 at 09:46 PM

avatar image

Shadowriver
33.2k 915 164 1088

(comments are locked)
10|2000 characters needed characters left
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