Ability/Action bar

Hero98

New member
Hello,
I am just curious is it possible to create a ability bar with the ultimate FPS. I.e. I was a bar when you press 1 you do one ability by clicking on the mouse and when you press 2 you do a different ability by click the mouse, also I would like to add a scroll wheel input so when the scroll wheel is on the first ability i.e. fireball ability you shoot a fireball then you move forward on your mouse wheel and you go to the next ability and the player can easily switch between abilities.

Thank you for the help in advance

 
You should just use Magic Items for this. Magic is just another ItemAction like any other (like ShootableWeapon, etc). You can think of each ability as being like a different weapon, and when you press 1/2/3 etc. you "equip" that ability. So you can just create a different Magic item for each ability and give the player 1 of each item in their starting inventory, and setup everything the same as you would with normal weapons. The same for scroll wheel - you can use the Equip Next / Equip Previous abilities to switch between the Magic items using the scroll wheel. (The demo already has a setup just like this)

Then the actual ability bar UI you would need to create yourself, there are a couple of different ways you could do this, you should start by looking at the demo's UI - in particular look at the "UI" section on the Items, and the Slot Item Monitor components in the UI canvas.
 
Hi thank you for the response @Andrew I got the first action in the action bar but I have one problem when I shoot the fireball I don't want to shoot another fireball immediately I want to wait lets say 5 seconds and then shoot another one. Also how could I get as for example a bool so after 5 seconds have gone past the bool i.e. readyToShoot is set to True. Also one last thing I want that time i.e. 5 seconds to fill up a bar slowly. Thank you for the help in advance
 
The UsableItem has a Use Rate so you could use that. Filling up the bar would be done by your new script.
 
Hi thank you for the help @Justin I am so close I just need help with 1 thing I am using the fireball magic item and I set the use rate to 5 and I got a reference to that in my action bar code. When I say if(timer >= magicItem.userate) it says that the use rate is 0 so what I done is I set up the timer so when it is greater or equal to 5 it displays the item as it should be able to attack again but when I try attacking it still does it and I am not sure why. I was wandering in the use rate do you use Time.deltatime to calculate how long should the character wait until the character can attack again or do you do something else to calculate time and how can I add this to my script. Thank you for all the help you guys are giving me sorry if my questions are slightly annoying its just I dont know where else I can go to get these answers
 
Hi thank you for the help @Justin I am so close I just need help with 1 thing I am using the fireball magic item and I set the use rate to 5 and I got a reference to that in my action bar code. When I say if(timer >= magicItem.userate) it says that the use rate is 0 so what I done is I set up the timer so when it is greater or equal to 5 it displays the item as it should be able to attack again but when I try attacking it still does it and I am not sure why. I was wandering in the use rate do you use Time.deltatime to calculate how long should the character wait until the character can attack again or do you do something else to calculate time and how can I add this to my script. Thank you for all the help you guys are giving me sorry if my questions are slightly annoying its just I dont know where else I can go to get these answers
Hi, if you cant do this I see a state called CanUseItem is it possible to track when the item can be used or not and how do I do that because if I can get that from my magic Item then I could say if(magicItem.CanUseItem) then I can do my code. Thank you for the help again
 
Hi, if you cant do this I see a state called CanUseItem is it possible to track when the item can be used or not and how do I do that because if I can get that from my magic Item then I could say if(magicItem.CanUseItem) then I can do my code. Thank you for the help again
This is my code for my action bar:
 

Attachments

  • code.PNG
    code.PNG
    40.5 KB · Views: 7
Are you saying that the Use Rate isn't working on the magic item? E.g. in the demo scene the Fireball has a Use Rate of 0.1, if I increase this to 1 then the fireball will only be useable every 1 second.

Yes, you can definitely use MagicItem.CanUseItem to determine if the item is useable, which is how I would recommend using it for the purposes of your UI.
 
Top