This is a bit of a big question. Mostly just looking for advice. I am trying to create a system in which players can pick up and put down objects inside of a trigger box that belongs to their team. Each team will gain points for their score in the UI based on the objects within their team’s trigger box. Points will be reduced if those objects leave that trigger box.
My current thinking is that this can be achieved by creating tags for all of the BP “Objects” that can be picked up. Those tags must then somehow be assigned a certain number of points. From there I know that in order for it to detect the objects I need to make use of OnActorBeginOverlap (and its counterpart OnActorEndOverlap) with the trigger box and then somehow feed the objects into an array… not really sure how to do that part. From there it needs to count the objects in the array and change the UI text to match the counted number.
This doesn’t seem that complicated but I’m not really familiar with blueprints and I can’t find any tutorials that are really in line with this. Am I even on the right track?
hi,
i made a little example of how you could achieve this with minimal work
ok here is the demo
here are the steps in a few screenshots
ok this will be on your character with the interface which comes later… where you see the DropItems Array, you could sort items for distance for example if they overlap,… depends on your needs
this is the DropItem base class… i made it so you can make different branches but allways have the base as a reference… value would be the points of the item…
Wow, thank you this is an incredibly detailed answer. I will take a look and give it a whirl after work, then I will mark it as a solution. Thank you so much!
p.s. the arrow component where i attach the object too might be better to switch to a socket… there you have rotations of your character if you want that
The only use of the word points I could find was when you append the value to “points” and to be honest, I’m not sure what that does, but it does not seem to make it so you can reference “Points” anywhere.
Lastly, what do you mean by using the WID_DropItem widget on everything? The screenshots all show a widget on the dropItem and the goal zone, are those supposed to be the WID_DropItem somehow?
Update I figured out the widget thing. It’s just replacing the class component within the blueprint.
“Points” is just a Variable (int) in the BP_GoalZone… just create it and plug it in (can have an other name too, does not matter) this is the holder for the points which get send via interface… (ahh sorry, it is a Local Variable inside UpdateStats, thats why it is not shown on the main bp, my bad ) the string append is just for the Widget Text… you can type anything here, i just used points but it can be score too (just for points in zone + any text after)
DropItem and DropZone use both the same Widget (WID_DropItem) just because it is just a plain text widget and it can be adjusted for their needs…
i can make a few more screenshots if you like
can upload you the BPs as .rar if you like, the character you need to setup then alone, or you may have issues with two mannequins ?
will be online tonight, if you need anything i am here
Okay awesome, yeah I figured out that was the use of the append “points” I even added in a little space before the word to make sure it looked right in-game.
I just made a variable for points in update stats, so that’s taken care of.
The thing I’m still struggling with is the events in my third person controller.
You seem to have made events using the functions from BPI_DropItem…
yes the character has the interface too… (first picture) add the interface and compile it… then you can go to interfaces and there should be the functions, right click them and use implement event
I seriously had to scan through that picture 5 times before I realized the difference, but I have the interfaces now. Thanks a million. I can pick the pot up now, but it’s being carried about 50 meters away from my character haha.
the camera inside can be that you drop the item to close to the character…
and i see in the picture you just add the item… you need the if not contains item or it will add it several times
here are the bp´s… character is not included but everything else (standard ue4 manny) CollectorGame.rar (52.1 KB)
just drop it in via explorer and for safety do a right click on the folder and pick “Fix Up Redirectors”
hope this helps you the array needs the NOT contains item or it will fails to remove it… but you can check the bp´s and delete them later or keep em… i had no issue copying the files in a new project…
Still trying to figure this out believe it or not. I don’t see what you say you see in the pictures. As far as I can tell all of the blueprints are exactly the same. It still just doesn’t update correctly on the widget text. My blueprints are removing the item from the “items in area” array just fine, it’s just not updating the points correctly, and for the life of me, I can’t figure out why. I made the items in the area array and points variables public to check. So it seems to me the issue must lie with the way it’s updating stats…
-but that is also exactly the same.
If you’re saying it’s an issue with the event graph on the dropzone, I don’t see how that can be the case either because I’ve tried it the same as yours (I added a print string for debugging).
P.S. the files you supplied don’t seem to play well with my project, or even a new project imported. They break and spit errors, but I was still able to look at their structure, and the structure is exactly the same. So I don’t know what’s happening.
hi,
i think the issue with the points is that it is a local variable… so it should reset each time you count points… you could make it local or set it to zero before the ForEach Loop in UpdateStats
I went with the zeroing-it-out method. Thank you so much for all of your help, I hadn’t intended for this to be a month-long problem. I have marked your original response as the resolution.