• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help on what happens, programming wise, when selecting an ability

Status
Not open for further replies.
Hey guys.

Note that I am not looking for a way to do this in War3.


I am trying to create a system in C# where a player selects a unit and can then select an ability which the selected unit is able to cast. More or less how it is in War3.

But I am having problems wrapping my head around it. So I thought I would figure out how they have done it in War3.

So I guess in War3 the game detects when a player clicks on an ability. Is this ability (and all abilities) derived from a Base_Ability?
And when an ability is clicked how does the game know this and is the information stored anywhere?

I would really appreciate an in depth explanation of what happens from the point a player selects a unit to selecting an ability, to casting said ability.

Hope you can help me out.



P.S.
If this in the incorrect forum for this thread please move it to the appropriate forum.
 
So, you want to create a game in C#, and in your game you should be able to add an ability to a unit?

Yes to the create game in C# and no to the game being able to add an ability to a unit (well, at least for now).

What is boggling my mind is how the ability selection of a player works.

Like.
What happens when a player selects a unit? Will this unit get stored in a variable for future reference? Does the unit link to an owner of sort?

What happens when a player selects an ability of a unit? (Same questions as above)

How does the actual targeting work? Does the spell wait for a loop to be true? (Eg. the selecting player selects a target when the spell has been selected) and so on.

These questions are based on what GUI functions I know of in War3. And War3 is my reference to get a basic idea on how this sort of thing is handled.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Depends on the code.

If you are coding from scratch, you are the one who decides how all of that works.
I only worked with 2D games when I made games in C#, but this is basically how it would look like to trigger unit selection:
Code:
for(int i = allUnits.count; i > 0; i++)
{
    if(allUnits[i].X - mouse.X < hitbox.X && allUnits[i].Y - mouse.Y < hitbox.Y && check if right mouse button is down I have forgotten the syntax)
    {
        selectedUnit = allUnits[i];
    }
}

Said code is for singleplayer.

edit:
On second thought I would use rectangles to check for intersection, but that's a XNA feature, if you use another engine it might not exist.
 
Depends on the code.

On second thought I would use rectangles to check for intersection, but that's a XNA feature, if you use another engine it might not exist.

Heh sure I decide. But I might as well try to use a method that is solid to begins with :)

Ah. I think I didn't make myself clear.
When I said "selects a unit" I meant a single target unit. As in, when the player left click on a unit.
The selection of a unit is not the most important right now though. It's more the selection of abilities.

But for selection of a unit I have something like this for now.

void Update()
{
if (Input.GetKeyDown((KeyCode.Mouse0))) //left click
{

if (hoverTarget != null)
{


if (hoverTarget.tag == "Ability") {
abilitySelected = hoverTarget;
}


if((hoverTarget.tag == "Enemy" || hoverTarget.tag == "Character")) //check what the tag of the object being mouse hovered at the time of clicking
{

//This is where it gets interesting. Right now I store the selected ability in a variable in the Player_Controller script. And that works. It's the targeting of the ability which causes the biggest headache.
if(abilitySelected == null)
{
selection = hoverTarget;
}
else
{
target = hoverTarget;
}
}

Debug.Log (hoverTarget.tag);
}
}
}

I have set up a Base_Ability script which all spells(abilities) derive from.
I think it's best to have the targeting function in the ability script instead of in the Player_Controller script.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,011
I think it depends if different abilities have different types of targeting or they're all essentially the same. If the latter then you could do it in the player controller script like a default way that gets overwritten by special cases for specific abilities. Otherwise just have some sort of ability class that you selection.TheRelevantAbilityStructureHoweverYouGetIt.runTargeting().
 
I think it depends if different abilities have different types of targeting or they're all essentially the same. If the latter then you could do it in the player controller script like a default way that gets overwritten by special cases for specific abilities. Otherwise just have some sort of ability class that you selection.TheRelevantAbilityStructureHoweverYouGetIt.runTargeting().

I think War3 must have some kind of base structure for abilities which all abilities derive from. I base this on the Channel ability where you can set target types (universal, unit target etc.) and also which "tags" can be targeted (human, orc, undead etc.).

But what happens programming wise when the player click on an ability? Fx. the player select Blizzard from the Arch Mage. Will the selection get stored until a target area is selected? Or will the spell itself wait for the player to react?
 
each cell on control panel has it's own watcher which detects hotkeys pressing or ButtonPressed event, if you wonder. and sure, wc3 has storage for currently selected/active unit, as well as many other links updated in real time

Ah interesting.
I don't know if you are familiar with Unity Engine. But those cells you mentioned. Are they a physical object or UI specific?
And regarding abilities. Do they replace a cell in the command UI or "morph" into the cell?

And you mention War3 store selections. So does this mean when a player click an ability in the command panel it stores the selected ability in a player_controller-ish function or is it stored in the actual cell?
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
its ui, surely. every time game window renders it goes through all abilities unit has, placing them on desired/available cells, until all abilities are done. unless it's ward unit type or non-controlled, of course. while doing that, it also registers hotkeys and possible clicks.
whenever you select an ability game checks what it based for, get up with proper targeting image and enable special mode "select target". ability itself has no effect on it except if removed mid-targeting, which causes immediately close of this mode. not sure which other info cell stores, but basically it has no idea what kind of spell it contains until interacted
 
its ui, surely. every time game window renders it goes through all abilities unit has, placing them on desired/available cells, until all abilities are done. unless it's ward unit type or non-controlled, of course. while doing that, it also registers hotkeys and possible clicks.
whenever you select an ability game checks what it based for, get up with proper targeting image and enable special mode "select target". ability itself has no effect on it except if removed mid-targeting, which causes immediately close of this mode. not sure which other info cell stores, but basically it has no idea what kind of spell it contains until interacted

I see.
So those abilities we see in the command panel are in fact just ability-placeholders, or shells, or some form of base structure for abilities.
How does the game know what ability is "behind" the placeholder and furthermore how does the game know what to execute once a target has been selected if the actual ability information is not stored in the placeholder?

I don't know if you have access to the code behind all this. But that would probably be very helpful.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
What you basically want to have first is the detection of when a player clicks the UI button or presses the hotkey.
At that moment, you load in the ability that has to be cast on whatever way you desire.
Then you do something like "myAbility.getTargetingType().startTargeting()".
Note that you have to create some targeting types in your code.
(Simple interface and a few classes that use it.)

As soon as the player finishes the spellcast (on whatever way that is done by the targeting type), you then reset the UI and start casting the ability.
The targeting type for instant casts would simply have an empty startTargeting().
The targeting type for point casts would have a mouselistener and checks when the player clicked on the terrain (aka, in the world).
etc.

To know what ability is behind it, you have to keep track of it.
Aka, when an ability is added to a unit, you add it to a list of UI buttons for that specific unit.
(You could also read these in on selection, but that is performance vs memory.)
Anyway, you have an object that listens to the UI input, and that object knows which ability is linked to it.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
every cell keeps hotkey and probably other info, including reference link onto ability address. every ability has its own unique address, so it's make sense to store it along. whenever you click, it uses this address to get targeting type, as well as any further info later. it provides indirect access to data like manacost, cooldown etc, yet all those links are linked. OOP is heavy in WC3
 
I think you need to break it up a bit more.

What you basically want to have first is the detection of when a player clicks the UI button or presses the hotkey.
At that moment, you load in the ability that has to be cast on whatever way you desire.
This is one of my issues. How will I "store"(or link) an ability to a specific UI element? I need to get this right in order to load in the specific ability.
I know how to detect when an UI element is being interacted with but the link to the ability, not so much.

Wietlol said:
Then you do something like "myAbility.getTargetingType().startTargeting()".
Note that you have to create some targeting types in your code.
(Simple interface and a few classes that use it.)
Yes. So each ability (or the base ability from which all abilities derive from (here set what type of ability it is (unit target, area target etc.) and all sorts of basic parameters all abilities use)) will have a few functions. As you wrote, a getTargetingType() function, a startTargeting() function, and perhaps an execution() function?
But when the chosen ability has been found, a target type determined, and the startTargeting() is running I also need to detect when the ability is being used (eg. a target is found (be it environment, unit, or instant)).

Which leads to:

Wietlol said:
As soon as the player finishes the spellcast (on whatever way that is done by the targeting type), you then reset the UI and start casting the ability.
The targeting type for instant casts would simply have an empty startTargeting().
The targeting type for point casts would have a mouselistener and checks when the player clicked on the terrain (aka, in the world).
etc.
That's exactly it. In what way can I detect when the player selects a target for the ability, and how will the game know that it is THAT ability that has a target chosen?

Wietlol said:
To know what ability is behind it, you have to keep track of it.
Aka, when an ability is added to a unit, you add it to a list of UI buttons for that specific unit.
(You could also read these in on selection, but that is performance vs memory.)
Anyway, you have an object that listens to the UI input, and that object knows which ability is linked to it.

So kinda:
- The player selects a unit.
- The unit selected is stored in the Player_Controller script as selectedUnit (variable) = the unit the player has just selected (I detect this via mouse input, some ray casting, and some tag filter (eg. if object hit by the raycast has the right tag, the set selectedUnit (variable) to the hit object)).
- The unit has a list of abilities. I guess a variable like this; abilityList[] holds all of said unit's abilities.
- These abilities in the list must then somehow be shown in the UI (this is pretty crucial and is also one of my headaches)
- The player selects an ability from the unit's UI
- The ability is also stored in the Player_Controller script (or?) to keep track of which ability is currently selected.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
This is one of my issues. How will I "store"(or link) an ability to a specific UI element? I need to get this right in order to load in the specific ability.
I know how to detect when an UI element is being interacted with but the link to the ability, not so much.
Do you know what OOP is?
Basically "private AbilityType abilityType;" (dunno if that is correct syntax as it has been ages since I used C#)

You have a base type for a UIButton, then you have AbilityUIButton which extends UIButton.
The AbilityUIButton class has a field which leads to the ability type.

WC3 uses integers for this with probably some map to look up the data (or whatever).
Maybe you already have something to define and like ability type, I dont really know, but you need something to link to them.

Yes. So each ability (or the base ability from which all abilities derive from (here set what type of ability it is (unit target, area target etc.) and all sorts of basic parameters all abilities use)) will have a few functions. As you wrote, a getTargetingType() function, a startTargeting() function, and perhaps an execution() function?
But when the chosen ability has been found, a target type determined, and the startTargeting() is running I also need to detect when the ability is being used (eg. a target is found (be it environment, unit, or instant)).
How I would do it is to make the Ability class have a field which is the AbilityTargetingType.
This AbilityTargetingType is an abstract class or interface that has all the different types of targeting types as childs with static instances so they are accessable from anywhere in the code.

To check when the target has been found, you put all the conditions inside the child classes' startTargeting() (or whatever) function.
This one has to keep polling or listening for whatever is required and then executes the abilitycast with the targets and stuff as parameters.

These abilities in the list must then somehow be shown in the UI (this is pretty crucial and is also one of my headaches)
So you say that you cannot yet show the buttons right?
In that case, you shouldnt yet continue with the targeting.
But in any case, when you select the unit, you want to redraw the UI, in that function (the UI draw), you loop over the abilityList and create AbilityUIButton instances with the ability and unit as parameters.
The AbilityUIButton constructor with the ability and unit parameters then reads out the icon of the ability, the icon position of the ability, the hotkey of the ability, the tooltip of the ability, etc, etc, etc. (if you wish, you read out the abilitylevel from the unit so you can have those visuals depend on the level and whatnot... WC3 only uses that for the name and tooltip and cost and stuff.)


The ability type is given as parameter with the startTargeting so it can be returned at the end of the targeting sequence... including loading in the targets allowed, error messages, etc, etc, etc.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
oh btw, just got it, since im able to dinamycally change hotkeys, they arent' stored either, game must be going through all of abilities again.

edit:
indeed it is. everytime any key pressed (including mouse) game goes through all available hotkeys
 
Last edited:
Do you know what OOP is?
Basically "private AbilityType abilityType;" (dunno if that is correct syntax as it has been ages since I used C#)

I'm not exactly sure what OOP entails even though I have read up on it.
I believe you think of enums, so it would be "private enum AbilityType abilityType". I actually already have that.

Wietlol said:
You have a base type for a UIButton, then you have AbilityUIButton which extends UIButton.
The AbilityUIButton class has a field which leads to the ability type.

This I need to read up.

Wietlol said:
WC3 uses integers for this with probably some map to look up the data (or whatever).
Maybe you already have something to define and like ability type, I dont really know, but you need something to link to them.

How I would do it is to make the Ability class have a field which is the AbilityTargetingType.
This AbilityTargetingType is an abstract class or interface that has all the different types of targeting types as childs with static instances so they are accessable from anywhere in the code.

By using integers you mean as some sort of ID mark ye? I have noticed when creating a new ability in War3 (with the NewGen editor) that a 4 letter number is generated.
Here I have been using an enum again (private enum TargetType targetType).
And then having 3 functions (since I only have 3 target types as of now). Each function would have it's own characteristics.

Wietlol said:
To check when the target has been found, you put all the conditions inside the child classes' startTargeting() (or whatever) function.
This one has to keep polling or listening for whatever is required and then executes the abilitycast with the targets and stuff as parameters.

I'm guessing a Ienumerator (coroutine) to check when the conditions has been met. Again something I need to read up on since it confuses the hell out of me.

Wietlol said:
So you say that you cannot yet show the buttons right?
In that case, you shouldnt yet continue with the targeting.
But in any case, when you select the unit, you want to redraw the UI, in that function (the UI draw), you loop over the abilityList and create AbilityUIButton instances with the ability and unit as parameters.
The AbilityUIButton constructor with the ability and unit parameters then reads out the icon of the ability, the icon position of the ability, the hotkey of the ability, the tooltip of the ability, etc, etc, etc. (if you wish, you read out the abilitylevel from the unit so you can have those visuals depend on the level and whatnot... WC3 only uses that for the name and tooltip and cost and stuff.)


The ability type is given as parameter with the startTargeting so it can be returned at the end of the targeting sequence... including loading in the targets allowed, error messages, etc, etc, etc.

So will I need a list of ALL abilities in the game? Or can these abilities rolled through be just the ability list of the selected unit?
Because an assassin class surely don't need to check for mage abilities.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I believe you think of enums, so it would be "private enum AbilityType abilityType". I actually already have that.
I wouldnt do that if I were you.
You are saying that you want an enum for ALL abilities in your game?
Imagine this in WC3. WC3 (TFT) has 778 standard abilities... which would be a 778 stances enum.
I mean, what the hell?

You want to have a reference to your ability, like how WC3 has an integer (aka, 4 byte variable, aka 4 character code) for example 'AHds' (Divine Shield), then you have to be able to read out the ability data of that ability without looping through all abilities in your game.
I dont care if you do it by an integer code and map lookup, or by creating objects for each ability in your map with a reference to the instance, or whatever, but you think of how you want to do it.

You definately do NOT want this to be an enum, but a normal field, with type AbilityType or integer or something like that.

This I need to read up.
Abstract classes or interfaces are simply blueprints with certain requirements for classes.
If a class extends an abstract class, it has to implement the abstract functions that this abstract class has, so you can guarantee that any extension of this class has an implementation of the required functions like "startTargeting()".
Same with interfaces, except that interfaces cannot have constructors, but you can only extend 1 abstract class, but implement infinite* interfaces.
(* theoretically a countable infinite)

Here I have been using an enum again (private enum TargetType targetType).
In this case, an enum could be used, because you have a limited amount of targeting types.
However, creating a new targeting type in the long run really is going to be a pain.
I, for myself, would use an abstract class and implementations as well, but this one is up to you.

So will I need a list of ALL abilities in the game? Or can these abilities rolled through be just the ability list of the selected unit?
Because an assassin class surely don't need to check for mage abilities.
You dont want to search for an ability.
It is like having the custom value (where the value is a unique integer between 0 and 8191) of a unit and you want to have the unit with that custom data.
Do you want to loop through all units on the map? or do you want to have an array of units with the unit stored with the custom value as index?

Ofcourse you do not want to have to loop through all units on the map.
But the first thing you want to ask yourself is, "Why do I have the integer but not the unit?" because you can use the AbilityType much better than comparing it to all the abilities.
 
I wouldnt do that if I were you.
You are saying that you want an enum for ALL abilities in your game?
Imagine this in WC3. WC3 (TFT) has 778 standard abilities... which would be a 778 stances enum.
I mean, what the hell?

Yes that makes sense.

You want to have a reference to your ability, like how WC3 has an integer (aka, 4 byte variable, aka 4 character code) for example 'AHds' (Divine Shield), then you have to be able to read out the ability data of that ability without looping through all abilities in your game.
I dont care if you do it by an integer code and map lookup, or by creating objects for each ability in your map with a reference to the instance, or whatever, but you think of how you want to do it.

You definately do NOT want this to be an enum, but a normal field, with type AbilityType or integer or something like that.

Let's say I use integers to index my abilities. Can I automate the IDs of the abilities or will I need to manually write an ID for each ability?

Abstract classes or interfaces are simply blueprints with certain requirements for classes.
If a class extends an abstract class, it has to implement the abstract functions that this abstract class has, so you can guarantee that any extension of this class has an implementation of the required functions like "startTargeting()".
Same with interfaces, except that interfaces cannot have constructors, but you can only extend 1 abstract class, but implement infinite* interfaces.
(* theoretically a countable infinite)


In this case, an enum could be used, because you have a limited amount of targeting types.
However, creating a new targeting type in the long run really is going to be a pain.
I, for myself, would use an abstract class and implementations as well, but this one is up to you.

Ah abstracts. Those and virtual are a still a bit confusing.
Shoot. This would probably be a lot easier with some hard examples. I'm having troubles visualizing it.

You dont want to search for an ability.
It is like having the custom value (where the value is a unique integer between 0 and 8191) of a unit and you want to have the unit with that custom data.
Do you want to loop through all units on the map? or do you want to have an array of units with the unit stored with the custom value as index?

Ofcourse you do not want to have to loop through all units on the map.
But the first thing you want to ask yourself is, "Why do I have the integer but not the unit?" because you can use the AbilityType much better than comparing it to all the abilities.

This really makes sense though. Though 8191 sounds like a fairly small amount. Not for my project, but in general. I can't believe they have taken this approach in fx. World of Warcraft.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
I wouldnt do that if I were you.
You are saying that you want an enum for ALL abilities in your game?
Imagine this in WC3. WC3 (TFT) has 778 standard abilities... which would be a 778 stances enum.
I mean, what the hell?
wc3 has a list of all callbacks, every ability has like 10 links onto it, and proper function offset is calculated real time every time you asks for spell. wc3 have pretty big overheat yet worked smoothly even at 2003. u're just too afraid of nothing
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Let's say I use integers to index my abilities. Can I automate the IDs of the abilities or will I need to manually write an ID for each ability?
index += 1? (or index++;) (dunno if unsigned ints exist in C#... they should at least.)
You could also make a parser to a 4 character code or even a bit longer to make you only require printable characters.

Though 8191 sounds like a fairly small amount.
It is simply how we work in JASS, as soon as an array in jass reaches an index higher than 8191, it gets out of bounds.
The actual game should be able to have more than that amount of units, but it would be a big pain for the movement though.

u're just too afraid of nothing
I am not an efficiëncy expert, but I do see when things could be much better... at least if it is this obvious.
I am not saying it is going to ruin the game, but in my opinion, you should consider taking things from a better approach whenever you see one.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
I am not an efficiëncy expert, but I do see when things could be much better... at least if it is this obvious.
I am not saying it is going to ruin the game, but in my opinion, you should consider taking things from a better approach whenever you see one.
ye, so I though until saw wc3 inneries. goddamn it have so many, incredible amount of runtime loops throught many non-ever-gonna-be-useful staff, its funny how game never goes fatal or something under normal conditions.
 
index += 1? (or index++;) (dunno if unsigned ints exist in C#... they should at least.)
You could also make a parser to a 4 character code or even a bit longer to make you only require printable characters.
Hoho yes thank you ;)
But I need to index before the game start I guess? And how will I achieve this without manually typing in an ID?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I dont really understand the question.

Whenever you create an ability, you just give it a unique integer aka index++;
This is the same how the Object Editor works, except you can also choose your own prefered value (in a 4 char code format only using printable characters).
You probably do not have an object editor, but it should be pretty easy to do it.
 
I dont really understand the question.

Whenever you create an ability, you just give it a unique integer aka index++;
This is the same how the Object Editor works, except you can also choose your own prefered value (in a 4 char code format only using printable characters).
You probably do not have an object editor, but it should be pretty easy to do it.

Oh you are thinking of the editor. I'm not trying to do this in War3:

Solu9 said:
Note that I am not looking for a way to do this in War3.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I know, but the editor was just an example.
As I said "You probably do not have an object editor".
The second part of that sentence might be a bit confusing but I meant that it should be pretty easy to add that index++; somewhere in your AbilityType constructor(s).

You see, I have no idea how you create all these ability types, but there must be some function being called that creates a new one... that one should give the unique index... if you choose to use the integer references that is.
 
Okay.
I think I need to go back to the basic. Because right now it all feels quite abstract to me. I think I need some real examples on how this is done (or can be done).
Hold my hand and walk me through it.

This is what I have so far (I have deleted what I believe unnecessary information like health, mana and so on.)
This is not necessarily the way I WANT it, just what I have come up with.

Player_Controller (The script which controls what the player interacts with):
Code:
using UnityEngine;
using System.Collections;

public class ControllerPlayer : MonoBehaviour {

    public int playerID;

    public GameObject selection;
    public GameObject abilitySelected = null;
    public GameObject target;
    public GameObject hoverTarget = null;
 
    void Update(){

        //The target which the mouse points towards
        hoverTarget = MouseOver();

        //If left-clicking
        if (Input.GetKeyDown((KeyCode.Mouse0)))
        {

            if (hoverTarget != null)
            {
          
                if (hoverTarget.tag == "Ability") {
                    abilitySelected = hoverTarget;
                }
          
                if((hoverTarget.tag  == "Enemy" || hoverTarget.tag  == "Character"))
                {
                    if(abilitySelected == null)
                    {
                        selection = hoverTarget;
                    }
                    else
                    {
                        target = hoverTarget;
                    }
                }

          
                if(abilitySelected != null)
                {

                }
          
                Debug.Log (hoverTarget.tag);
            }
        }

        //If right-clicking
        if (Input.GetKeyDown((KeyCode.Mouse1)))
        {
            if (selection != null)
            {
                //If the player has selected an ability then deselect the ability
                if(abilitySelected != null)
                {
                    abilitySelected = null;
                }
                else
                {
                    //Order the selected unit to move
                }
            }
        }
    }

    public static GameObject MouseOver()
    {
        Ray rayHover = Camera.main.ScreenPointToRay(Input.mousePosition);
  
        RaycastHit hitHover;
  
        if (Physics.Raycast (rayHover, out hitHover, 1000f)) {
            return hitHover.collider.gameObject;
      
        }
        else
        {
            return null;
        }
    }
 
}

Note: I don't want the ability selected to be a GameObject, but I am unsure how to store it (I guess as an int based on the abilityID).
Abilities should not be GameObjects but links from a UI button/image being clicked.




Ability_Base (The scriptable object from which all abilities derive from)
Code:
using UnityEngine;
using System.Collections;

public abstract class Ability_Base : ScriptableObject{

    public string abilityName = "New Ability";
    public int abilityID;
 
    public enum TargetType{NoTarget, Unit, Ground, Unit_Ground}
    public TargetType targetType;
 
    public enum DamageType{Physical, Fire, Ice, Electricity, Poison, Magic, NonDmg}
    public DamageType damageType;
 
    public float castTime;
    public float coolDownTime;
    public GameObject projectile;
    public float range;

    public abstract void Activate(GameObject target)


}

In here I also wanted to check if the ability has been clicked and/or if a suitable target found.
I have considered having two Ienumerators running. One to check if this ability has been selected and one for if a target has been found.
This is where my first major obstacle is.


Am I going in the somewhat right in the direction?
 
Last edited:
right now, I would focus on detecting if the mouse is over UI or not.

Right. I think I got that covered now. But I need a script for the UI button so the game knows what method to run when the button is clicked.
This is just what I thought I would need.
The UI button will run the Activate method once clicked.
Based on the abilityStored integer it will run the ability with the same ID. But I don't know if ALL abilities in the game should be in the same list.
Anyway. Again please note that I have no idea really if this is the best approach (none of what I write is).

What happens in the Activate method is just placeholder.
Code:
using UnityEngine;
using System.Collections;

public class AbilitySlotButton : MonoBehaviour {

    public int abilityStored;

    void Activate()
    {
        Ability[abilityStored]SelectTarget();
    }
}

I guess I need to setup my base ability now?
 
Last edited:
Status
Not open for further replies.
Top