I figure this is an important use case that many developers will ask about.
Is it possible to build an MMO style action bar with these goals in mind:
- 8 actions with key bindings 1, 2, 3, ... 8
- Each action represents a different spell (fire ball, arcane missiles, etc)
- The bar does not change when the player changes weapons
- The player can set which spell goes in which action slot
- I would strongly prefer to use the Weapon Component, since it has so many built-in features (projectiles, damage, VFX, ammo, spread, etc).
I am not quite sure how to do this with the current Core systems:
Option: 1 Weapon with 8 Abilities
Yes, I can have a single weapon with 8 abilities, but the problem is that each ability really needs to have its own projectile, damage, and VFX and other settings. My Fire Ball, for example, is going to be much different than my Magic Missiles. But currently, the Weapon Component only allows you to define a projectile, damage, VFX, etc for the entire weapon, not on a per ability basis.
Option: 8 Abilities Parented To The Player
In this option, I would just parent 8 abilities directly to the player without using a Weapon Component. The problem with this is that I lose all the nice built-in features of the Weapon Component (projectiles, VFX, etc). I would have to manually code all of this.
Option: 8 Weapons each with 1 Ability
In this case, each action slot would be a separate weapon with only a single ability. The problem with this is that only a single weapon can be equipped at a time, and only a single ability can be used at a time. I would have to figure out a way to switch weapons each time an action bar slot is pressed.
So I am not sure if there is a better way to achieve this or not. Please let me know if you have any suggestions. Thank you.
In terms of the initial question of an "Action Bar" it's a user interface decision that can be built regardless of the problems outlined in each option. The answer is yes, an action bar like that could be built. The hardest part to me would be how the player selects which ability is assigned to which slot. In Core Content there is a template called "Ability Display" that is a good starting point to build the UI, but it would have to be reworked for this specific MMO design.
Regarding the options on how to assign the abilities to the players. A mix of option 2 and 3 is how I would approach it. You want it to be modular, where a player kit can be assembled from several abilities/weapons. The best way to do that is to keep them as separate templates.
In terms of standalone abilities that are assigned to the player (option 2) it may be better to have an Equipment object instead, and an ability under that, so you get a standard Equip/Unequip for the entire set. Weapons are Equipment and share the common functions. This would make the whole system a lot simpler.
You're under a misconception that a player can only have one weapon. If you are relying on the pickup trigger then this is true. However, if you :Equip() procedurally you can have as many as you want. Without writing any script you can add multiple Static Player Equipment templates to the hierarchy (Core Content) and assign a different equipment to each one. The player should begin the game with all of them. Each one with a set of abilities.
Your suggestions were very helpful, thank you!
With the API it does not seem possible to change the binding of an ability since the
actionBinding property is read-only. I would like my players to be able to change the spells in the action bar, which requires me to be able to change the binding of an ability. For example, if I want to move my Fire Ball spell from slot 1 to slot 2, then I would need to change its binding from key press 1 to key press 2.
Would it be possible for you to change the API so that the
actionBinding property is read-write, instead of read-only?
That would be great. Can you please make a feature request?
some news about this feature ?
Its already possible to creatue an action bar where you can freely swap abilities. You just have to set the key binding on each ability to none and activate the abilities with your chosen key binds yourself.
Here is a picture of my work in progress game, where players can equip up to 10 different abilities as they like:
It just needs a bit of scripting to spawn/destroy and connect/disconnect abilities.
I created a single piece of equipment with the geometry of an non-visible, con-collision cube, and attached it to the root socket, but you can attach to any socket, like nameplate. I put all special abilities into this single item and used the Static Player Equipment template to give it to players. Weapons can be swapped out at will and the abilities remain unaffected.
thanks, ( i don't see the static player equipement, seems nice)
Check in the NPC AI Kit on Community Content. I think that's where to find it.
Static Player Equipment is a template in Core Content. That's an interesting solution. When you call ability:Activate() if you do it on the server you'll have a bit of lag as the player input needs to go to the server then the activation needs to return to client, so the casting player will observe a full ping. If you detect the input on a client script and call the :Activate() then, the caster will see immediate feedback. Also a good moment to spawn SFX. Just make sure to compare the player pressing the bindings against the owner of the ability, otherwise one player pressing will cause all players to activate.
thanks you all.
i found the script, and i will try to use "activate and sfx" in client context