Hello,
My name is Luis Filipe and I have been working a Top-Down Arena Style hoard mode game for an assignment, it is a C++ project and I am not allowed to use blueprints.
I have a PickupActor class that should be added to the players inventory component when the “E” key is pressed. To accomplish that I wanted to have a USphereComponent in my Character class that when I press the “E” key would either activate or call a function that generates the collision events that frame. Since some items may already be inside the the sphere when the “E” key is pressed I can’t use the Begin or End overlap events.
One solution I have considered is registering the begin and end overlaps of all pickups by adding and removing their pointers to a map, but that sounds very bad.
Anyone know if there is a way to generate the overlap events this frame for all objects currently overlapping with the Component?
if you were using blueprints (i know you cant but theres C++ behind it) i would suggest the get overlapping actors node. then you could run a loop to check for any actors of your pickup class and add it to your inventory. I dont know c++ but i know anything you can do in blueprint is implemented from C++ its just a matter of finding the right script so it shouldnt be too much trouble to figure out.
hmmm the script looks good from what i can tell though i dont know C++ or the ue4 api so thats not saying much.
one thing i noticed that im not sure on is
TArray OutActors;
is there supposed to be an asterisk in there? its supposed to be just an array of actors. now i know the asterisk can be a wildcard in some languages so im not sure on the implication here. again though not a C++ guy and its been awhile since i wrote anything in a actual scripting language.
Yes the asterisk means it is a pointer to the actor not the actual object.
I have fixed it. It turns out you can’t have both of these line at the same time: