Hey
So there’s this minor issue I encountered but don’t know how to figure it out.
I have an array as some kind of inventory and it works perfectly, now I want to be able to set specific events that happens based on the weapon currently in the character’s hand, the way the character picks up a weapon is random so for instance an axe might be in index 1 now and later in index 5, so the position it’s placed is random and depends fully on the player, so assuming I have other weapons in the array and the player can switch weapons, how do I get a reference to the weapon currently in the player’s hands?
Any help is appreciated, thank you.
When you put it in their hands, you record the index in an integer
Thanks for replying and sorry I couldn’t give a response sooner. You see I’ve already done something like what you suggested, that’s the way I’m able to switch the weapons but each weapon has it’s own index variable, I have an independent index variable that responds to only an increment of the array, that way I can know the size and be able to switch from the last index to the first buh it doesn’t show which index is currently active because it resets to zero, I’m using the axis value of an input to switch between weapons, could you show me how you would setup what you suggested please?
You don’t need an index to tell you where to add to the array, because you can just use the ‘add’ node, that puts things on the end.
When you decide to equip item 3 in the array, just set
equipped item = 3
Then you always know which item they have.
Thanks for the help, I was able to get it working and no, I used an integer to represent the index to tell me exactly what weapon I have in hand, it’s a bit complicated and I went through alot of stress to be able to get the logic but it’s working as intended now, thank you, your suggestion helped alot
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.