Search Unity

Activating/deactivating abilities from UI

Discussion in 'FPS.Sample Game' started by BrianKraus, Jun 21, 2019.

  1. BrianKraus

    BrianKraus

    Joined:
    Jan 10, 2016
    Posts:
    7
    I want to be able to turn abilities on/off based off UI input from the user, but I'm struggling to make it happen.

    Right now I have a bool in the AbilityControl struct and I'm checking it at the top of the update function in the Ability_RequestActive system. The problem is I don't know how to set the value in AbilityControl from UI input.

    Is the best way to try to accomplish this? If so how do I set the bool in AbilityControl?
     
  2. Aquastar

    Aquastar

    Joined:
    Jul 17, 2013
    Posts:
    23
    You need to add a new member "Entity character" to AbilityCollection.InternalState and initialized it in HandleCharacterSpawn.Initialize. Then you get UserCommandComponentData from the character entity when update.
     
    AggressiveMastery likes this.
  3. BrianKraus

    BrianKraus

    Joined:
    Jan 10, 2016
    Posts:
    7
    Thanks for responding. I was able to get it working this way. Is there a way I can do it from GUI instead of using UserCommandComponentData?

    I'm having trouble understanding how to have GUI input interact with ECS.
     
  4. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    58
    You should be able to run UserCommandComponentData by clicking a GUI button or setting a GUI check mark.
    Try to add what you need to an existing menu like when you press ESC ingame or in the option menu.

    When you get this working you can then add a new menu (by seeing how Options work) to hold whatever it is you need.

    On a side note. You dont have to use ESC to make a new menu. You should be able to add it like you normally would before ESC were implemented.
     
  5. BrianKraus

    BrianKraus

    Joined:
    Jan 10, 2016
    Posts:
    7
    Nice. I was able to get it working. Thanks guys.