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"

Getting Actor Variables From An Array?

Hello all, I'm having a problem getting variable information from an array of actors. I want to add items into an array and pull up information from those items later. The problem is that when I try to get any of the actor's variables it says the variable is not in scope. I thought maybe because I needed to cast the item in the array, but it just keeps failing the cast.alt text

The strange thing is that if I look at the line coming off the first GET node it shows what actor is being referenced, but the item info is not in scope. Also, at the second GET node it will only print the item name if it's the first item I pick up. Even though I'm referencing the same item in the array, I can't get it to print the name on successive item pickups.

Product Version: UE 4.19
Tags:
additem.png (133.1 kB)
more ▼

asked Nov 27 '18 at 07:29 PM in Blueprint Scripting

avatar image

Goatmeal66
21 2 3

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

1 answer: sort voted first

I'm not sure what you wish ti print in the first PrintText but if you wish the print the name of the item you just added to your inventory, you'll need to get the item from the inventory using the index returned by the Add method. Here's an example:

alt text

I might have misunderstood your question. If so, please let me know, but I do hope this helps :)

tmp4.png (134.1 kB)
more ▼

answered Nov 27 '18 at 07:41 PM

avatar image

Detilium
71 3 9 10

avatar image Nebula Games Inc Nov 27 '18 at 08:11 PM

Agreed, right now your current set up will only ever return the "0" index of the array which will always be the very first item you pick up....ALWAYS.

avatar image Goatmeal66 Nov 27 '18 at 08:17 PM

I know that I can get the name of whatever I just put into the array, but if I want to get any information about the item after that, the variables are not in scope anymore. Say I pick up my first item. I can look at any information about that item right there. When I pick up my second item I want to see if the two items have the same name. The problem is I can no longer access the information of the first item. Even though when debugging I can see that the correct item shows up off the GET node, when I 'getItemInfo' it's no longer in scope.

avatar image Detilium Nov 27 '18 at 08:38 PM

Ah, I did misunderstand your question then. I just tried replicating your issue, but it works fine for me? Could you show us the details of the actors from the world outliner? The one that's already in the inventory, and the new one your adding?

avatar image Goatmeal66 Nov 27 '18 at 09:04 PM

I'm not sure I understand what it is your asking for. Here's a pic of my potions within the level and their info from the world outliner. I've also attached a pic of the overlap event with my character. I should note that it's the blueprint of a masteritem and that I have child classes for the health/mana potions. Maybe it has something to do with the way I set up the class structure?

alt text

alt text

levelpotions.png (730.1 kB)
masteritem.png (121.3 kB)
(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