Using an Actor within a Character
I know this must be a really stupid question but i couldn't find the solution. If this is a duplicate question, please link me the answer.
The problem is:
I made an actor called PickupItem
I made some pickup items from this class that when i walk nearby them, i collect the item. Now i want a Character to be able to give me the item when i'm close to him. So i made an NPC class
and tried to add
and on the constructor
And the Unreal Crashes (Even though the project actually compiles) Also tried with
But got the same result.
What i'm i doing wrong? i tried searching for something similar but all that i could found was on blueprint and parsing it to c++ didn't even compile.
Basically what i want to do is to be able to expose those attributes to a blueprint so i can later define then as the item that the player will get.
I tried to do a similar code as yours. My unreal crashes too. So I tried several things and eventually I success to do something which works.
Spawning actor in constructor seems not work so I moved the creation in the BeginPlay function.
NewObject didn't work for me so I used SpawnActor.
Here the code :
The header is similar as yours :
TestCharacter Is a paper character, equivalent to your NPC. APlayerShot is a child from AActor, equivalent to your pickup.
So like this I can access to my actor from a blueprint extend from my character :
I hope it will help you. ( Sorry for my bad english )
Follow this question
Once you sign in you will be able to subscribe for any updates here