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"

Safe an Actor in InventoryArray

Hi all,

i just want to test out a simple inventory, consists out of an array of actors.

What i have is the class AItem : AActor this only has a var ItemName which i want to display OnScreen.

And the class APlayerCharacter : ACharacter

So i made me a "TArray" TArray CharInventory; to store Items in it inside APlayerChar...

So for testing i tried to instance an actor inside the character which look like this: AItem* testItem = GetWorld()->SpawnActor(CharInventory[0], this);

this is the error i got at the moment: shows between the ptrArrow GetWorld()->SpawnActor no Instance of overloaded function "UWorld::SpawnActor" matches the argument list. Argument types are (AItem , APlayerCharacter )

nothing worked so far i only get errors on and on and i dont understand why. Could you help me out?

Product Version: Not Selected
Tags:
more ▼

asked Jul 14 '14 at 01:54 PM in C++ Programming

avatar image

Wallhalla
181 5 10 20

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

1 answer: sort voted first

Because SpawnActor requires UClass* which is class identifier from which you can create instance of a actor class, you can get UClass poiiter f using GetClass() from active instance or ASomeClass::StaticClass() from not instantiated actor where ASomeClass is name of your class.

Considering you already have a instance of something in array you should use that instance insted of trying to spawning it over again.

more ▼

answered Jul 14 '14 at 02:37 PM

avatar image

Shadowriver
37.2k 936 172 1116

avatar image Wallhalla Jul 15 '14 at 07:29 AM

well, special thanks for your fast reply.

So the inventory should just being created when the Pawn is lootable (or even a chest...) preventing having each object in the world an inventory at start. The Spawn of an item will be when OnLoot is called.

If i got you right from your reply i would do this like this. OnLootFunc() -> CreateInventory() -> Spawn Actor´s and Add them to Inventory Array -> Show Inventory().

I dont quite understand yet what method of your answer would be best for it, maybe you could help me a second time :)

(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