hello there. I’m building a system where a player can pick up different blueprints.
I need to increase my gun amount variable:if i hit a gun blueprint
-I need to increase my “WireCutter” Amount variable if i hit a wirecutter blueprint.
however, it’s increasing both…How could i fix?
Also I’m aware i could use collision channels, and individually pick which object…BUt there is a max of 18 collision channels, And i have more than 18 pickups in my games.
You could create an array of pick up and use the index value to set your gun amount (with a second array where each index fits the first one.) On picking you “find” index in first array and get variable in second one with it.
See i tryed adding the hit actor into an array… But when i check to see if it contains a certain object, It doesn’t give me the list of actors…SO i have to create a variable And set it to a specific actor " Test AR OBject" Not really sure if i’m doing that right…
When i place put a branch to see, it seems to print the string reguardless. Any tips… (Sorry if I bother you too much, this answer to this question is going to solve a lot of things in my game)
By reading it once again, i see that i may misunderstood your situation. If your pick up are different blueprints, you would have easier way by creating a parent blueprint pick up with empty mesh (you add static mesh in component with nothing selected) and create children with each different pick up you have.
Then you will “cast to” only on parent and all children will be recognized. In parent you create an integer variable and in child, in construction script, you set it to a value according to an array set in your character with all your weapons. When you have an event pick up you cast to parent, get integer from it, get in array the right weapon and add 1 to its max (or what you do to up it)
Will do a screenshot when i’ll have time to help you see if you have trouble doing it.
Here is a quick shot : First you create your parent pick up (i do a root box for overlap event and the empty mesh (which as not root can be scaled or modified as you want ) in component tab and an integer variable “type” in graph tab.
Right click on it in content browser : create blueprint based on this. I did it twice to have two children. In both : Check “Show inherited variables”, to see mesh and type. Set type and static mesh in construction script. In character blueprint : I created an array (in the example only a string one to see it working, you replace it by your own array, depending on how you set your weapons) with two indexes. On event overlap (same as line trace for effect) i check other actor with “cast to” and get “type” and use it to “get” weapon from my array.
Sorry i posted this up b4 the help…Do i got the system right though? Create a seperate blueprint of invetnroy containting all the stuff from the invetory…
My end goal: is to be able to pick up objects…Be able to store how many of that objects i have in my character bp.
The increasing number of how much i have is just to do that, but i could probably just do the same thing with an array.
When you use “cast to” from the output “hit actor”, you check that the actor you have hit with your linetrace is the one you cast to (and you create an access to its variables and functions). If you “cast to” “Blueprint_Inventory”, if this is not blueprint_inventory, as you link only on success, it will never work.
By using a parent blueprint, you have only one “cast to” and from it you get the variable type that you use to an integer array.(instead of the string one i used to show) If type is 0 you add 1 to value in index 0, if type is 1 you add one to value index 1. And you use the value to show how much you have with weapon with it.