- Home /
How do i change my attack depending on which item i have equipped?
so im making a 2D roguelike platformer game kinda like dead cells and dungreed but with magic and spells and i'm right now trying to figure out how to make an inventory system which tells the player which attacks to perform when i press the "Fire1" Input, so i need help with making such an inventory system and also i need help with being able to switch my spells depending on what spellbook i have equipped. I currently only have 1 spell Prefab set to shoot out like a bullet when i press space (i followed Brackeys old 2D Shooting in Unity video), i honestly have no clue how to add more attacks and how to make an inventory system so if anyone has a clue i could really use some help:)
I would implement this using an Finite State $$anonymous$$achine (FS$$anonymous$$), it's a design pattern that is often used. $$anonymous$$ight be a bit advanced though if you're new
Answer by S-khan · Nov 22, 2020 at 04:33 PM
First, Watch this https://www.youtube.com/watch?v=2WnAOV7nHW0 . Now, write a Switch Statement and attack according to case(s).
If you want a variant in your attack, you can store them in an array and use them as per your switch cases.
i'll try to implement that and let you know how it goes!
Your answer

Follow this Question
Related Questions
How to add diving to my script? 1 Answer
[UNITY 2D] Can I create a spawner that spawns another enemy after its death using IF statements? 1 Answer
Enemy's initial attack doesn't deal damage to player 1 Answer
Need help with my player attack script 1 Answer
How can i check if my Player was in the attack animation of my Enemy(2D) 1 Answer