Hi, I have a “shop” where I can buy two weapons in the game. When you buy them, the weapons will attach to the character. But I only want one to be attach at the same time. With this blueprint, if a buy the two of them, they will spawn in the same place, and I don’t know how to detach one.
So this code is saying to run both if both query skills return Verdadero. So, in case both are verdadero you can run “Destroy Actor” on Prota right before spawning Prota 2. That way you can guarantee only one actor is socketed there
Hi @Mind-Brain ! thanks for the answer, but it doesn’t work. I don’t know why, because the logic is perfect. I feel like once I pick in the shop the “weapon prota”, it just stay there, like the function is always working once is active. I don’t know if I am explaing myself well.
Is there a way to stop the function for working? Like code than only one function or query skills can be active at a time.
The idea in the future, is to have more weapons than you can buy, but you only can carry one.
First make a variable of “Actor-> Object”. You will SET this with the return value off the spawned weapon and before the “attach ActorToComponent” I suggest calling it “Equipped Weapon.” Do this in both lines of the sequence (and any new ones).
Now you will add the Destroy Actor to both lines where I told you, but instead of passing it like I showed you above, you’ll GET “Equipped Weapon” and destroy it BEFORE setting the new weapon.
So for both: Query skill->branch-> ifTrue->DESTROYACTOR with target: EquippedWeapon->SpawnActorWeapon(Prota,Prota2)->SET “Equipped Weapon” with return value from SpawnActor->AttachActor.
**Edit: I’m noticing your variable “Ajustar” there. That will probably function fine instead of “Equipped Weapon”. Just GET AJUSTAR and pass that into the Destroy Actor before the Spawn on BOTH lines **
Hello @Mind-Brain , thank you vey much for the steps. It is almost working!! If I buy the weapon 1 I get it.
Then if I buy weapon 2, it destroy weapon 1 and I get weapon 2. But, when I try to buy weapon 1 again, it doesn’t not apear and the weapon 2 is not destroy.
But it is working, because I tested with “print”, and It was there. If I change the order (1º buy weapon2 and then, weapon1) i get to the same point. With weapon 2 there and weapon 1 missing.
I been trying some things these past days without success, so I have to come again to ask for some of your wisdom.
You need these to be separate lines. I was thinking weapon 2 would always be an upgrade of weapon 1.
So you can do this two ways:
The first would be make another function and rename this one, so you have “Create sword 1” and “Create sword 2”.
The other would be to replace your sequence with a “select” node. To know which to select, you’ll click your purple “Create Sword” node and add an input on the Details screen, and change that input to an integer. After that there will be a little green integer input. So, when calling it you pass in an integer and then inside the function that needs to be hooked up to the select node. 1 function, multiple line options
This topic has been moved from International to Programming & Scripting: Blueprint.
When posting, please review the categories to ensure your topic is posted in the most relevant space. This post has been moved to a category that will help other devs with a similar question.
Well, I just realise the problem is the Query…it just doesn’t take the ID of the weapon, so it take all of them for some reason. So I will have to change some things. Thank you a lot anyways!