- Home /
How do I create a bunch of player abilities, with their own properties?
What I'm trying to do is create some kinds of list or enum to hold a bunch of premade player abilities. Currently I have:
public enum Abilities
{
NormalShoot,
MultiShot,
Blink,
FreezingFire,
RapidFire,
SelfRepair,
}
Which was okay when using abilities was extremely basic - I could just use Abilities.MultiShot when I was trying to use that ability. The issue is I want some abilities to have an energy cost associated with them.
The only solution I could come up with was having an array of Ability objects (a class I would create with all the properties in in), but I don't think it's a good way to go about this.
What would be the best way to go about this?
what it is not clear to me is: do you need to have each ability enabled but with different energy costs per player or rather to ENABLE different abilties at libitum for each player or both cases?
Answer by Firedan1176 · Dec 20, 2014 at 10:37 AM
Create a property drawer.
Unity Technologies also has a tutorial on how to create a property drawer.
A property drawer doesn't seem like it would help. Both those links say it's for UI and custom inspectors. All I wanna do is be able to create something like an Ability class, but have an enum or something similar of Abilities - I don't need to be able to create anything in the inspector or anything.
Hey
https://www.youtube.com/playlist?list=PLt_Y3Hw1v3QSFdh-evJbfkxC$$anonymous$$_bjUD37n
in this playlist watch video 5th i think this is exactly what you need !!!
He is using a Parameter class, applying different Parameter to different scenarios there by having multiple Parameter class for multiple scenarios.
You could create a dictionary which is an array with 2 variables.
I'm still kind of confused. Are you looking for something like this (from the tutorial I posted above)?
Answer by getyour411 · Dec 21, 2014 at 10:55 PM
It's an oldie but still a goodie, especially for someone learning C#:
http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial
Best to start from 1 you will learn a lot.