Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Any luck creating custom Abilities?

Discussion in 'FPS.Sample Game' started by gilsdank, Dec 1, 2018.

  1. gilsdank

    gilsdank

    Joined:
    Sep 17, 2013
    Posts:
    2
    It seems this is the best way to get some custom functionality without recreating all of the work these gentlemen have done.

    Has anyone had success rolling their own or modifying existing abilities? any tips are appreciated.
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,824
    This completely lost me.

    I will stop you here, since you are new.
    So instead speculating what you know, I will ask.
    How would you score your self, as Unity and C# user? Lets say 0 to 100 scale, where 0 i none.
     
  3. MasonEntrican

    MasonEntrican

    Joined:
    Sep 11, 2013
    Posts:
    8
    Abilities seem to define all broad user actions ie: movement , projectiles, grenade launchers, etc. So when looking to add new functionality such as an item spawner for example, creating a new ability .cs and adding it to the HeroType file seems to be where to focus. I think hes asking what Im asking myself aswell - would duplicating an ability and modifying functionality within be where to start?
     
    gilsdank likes this.
  4. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    Yes! @MasonEntrican , at least that what Mogens speaks to when being asked about making a basketball in FPS Sample, They talk about slowing down the grenade launcher weapon, and adding to it as a new alternate weapon:
    https://forum.unity.com/threads/how-would-you-go-about-making-a-basketball-type-object.582154/

    I've been thinking about the network structure like this, and I believe Peter confirms it in the networking deep dive video.


    That you generate script on the client and server equally, as you will use the client scripts to do prediction for client frame per second interpolation between server update packets. Then the server of course uses the scripts to do the authoritative predictions it then sends back out to the clients.

    So if you wanted to add a speed boost, you would start by taking jump and making a pure copy of jump and its script but called boost and bound to another key. Then figure out how to modify that version of jump, to boost or have the ability you want.

    Back in "the day"... Jedi Knight II, client's had access to their weapon definition file (what each gun shot, how fast the bullets went, how long they lived) and it was accepted as authoritative by the server/host... LOL So you would give a gun a 'platform' bullet model type to shoot, with speed of close to zero, and a life of 10 minutes. Then you had created a gun that allowed you to construct buildings out of bullets... aka Entities, aka Particles, aka Models. Choose your ability :D

    It's all in how you frame the visual update to the client, they don't know.

    GL HF,
    Micah
     
  5. MasonEntrican

    MasonEntrican

    Joined:
    Sep 11, 2013
    Posts:
    8
    Thanks for the in depth response! Thats essentially what ive been up to today. Been hitting odd snags here and there.

    My goal for the day was to be able to call a new "ability" from a new "command". For example ive been able to create a new command in the InputSystem.cs and use that command to call existing abilities - however when using that command to trigger the new ability, it doesn't actually see the command triggering.

    No errors and the prefab with the duplicated script shows up in hierarchy in preview mode properly with all replication assets associated. I think i've boiled it down to an issue with generating a proper GUID but im not positive yet. It seems to clear its guid on start for some reason.

    Here are the steps I took

    1) Created empty game object called New
    2) Added Game Object Entity Script Component
    3) Added Replicated Entity Script Component
    4) Added Replicated Ability Script Component
    5) Added New Ability_New Script Component
    6) Saved object as prefab within Gamedesign/Heroes/Robot/
    7) Copied C# contents of Ability_GrenadeLauncher to Ability_New.cs
    8) Renamed all classes within that utilized "Ability_GrenadeLauncher" in their name to "New_Ability" due to namespace conflicts (this may be my root issue here aswell so I will come back with fresh eyes tomorrow)
    9) Added new Abilities entry and associated the "New" prefab within Hero_Robot.asset
    10) Created a new command within InputSystem.cs tied to a new input key for testing
    11) Modified var fireRequested declaration in the override Update within Ability_New to utilize command.newAbility instead of command.secondaryFire
    12) Update Registry in project tools
    13) Build All [force]
    14) Build Game

    With this, the new ability does not fire and I do not get anything firing within the override update method. In fact the entire New_Update class within Ability_New doesnt fire. However the OnEnable() method does run so I know Im close.

    For debugging I tried utilizing the command.newAbility on the existing Ability_GrenadeLauncher, which does work. So Ive got that atleast lol.

    The biggest piece of the puzzle im missing currently is finding where the server is actually calling the update method for the ability ie: GrenadeLauncher_Update class
     
    Last edited: Dec 2, 2018
  6. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    Awesome stuff Mason (ill be trying this later) ! I know i'll dive deeper into this... Initially I want to be sure you are seeing that input make it to the server/host and not just registered locally/client side? Did you get that update into the network packets heading to the server?

    You could try reducing the complexity, and make the reply just be a movement or a color change seen from the server(or any small modification to what you have working), if it sees the button pushed. If we can get that, we should be on the right path.

    Antypodish, check out Abraham Hicks on Youtube, and learn to love :)
    https://www.youtube.com/user/AbrahamHicks

    Cheers
    Micah
     
  7. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    I happen to be looking around tonight, and I think the UserCommand.cs may hold where you can append the call from a new input for sending out to the server. Which is neat:
    strBuilder.appendline("newability": + newabilityvar); more lines would be needed as well above this, and like you have done as well.
     

    Attached Files:

  8. MasonEntrican

    MasonEntrican

    Joined:
    Sep 11, 2013
    Posts:
    8
    Thanks for the reply! I did actually find that aswell - and it does work using existing abilities, however the same outcome with the duplicated ability where it doesnt function. After restarting Unity the GUID populates correctly so Im going to widdle down the Ability classes to bare minimum.
     
  9. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    Howdy Mason,

    I was just reading up, as I am modifying the exploding barrel to become a car (Simple enough) and need a new GUID for that new pref, and so new abilities will need new ability GUIDs as well. Which is what the "Update Registry" does... It re-GUID's all prefs... Which needs to be addressed unity! As it takes a very long time, to slowly re-GUID all the assett prefabs in the whole game... Or maybe my editor is just hung. So instead of copying the prior ability's GUID, place a new ReplicatedEntityRegistry and then rebuild the register(update.)

    https://github.com/Unity-Technologies/FPSSample/blob/master/Documentation/SourceCode.md
    "ReplicatedEntity Module
    Handles replication of gameobjects and ECS entities.

    To replicate a gameobject, it must be a prefab with the ReplicatedEntity component attached. This will ensure the prefab is registered within ReplicatedEntityRegistry (any time build tool runs: "Update Registry"). Server and client have different ReplicatedEntityRegistry allowing for different prefabs to be spawned on the server and client. Each representing the same entity while simultaneously utilizing the same set of serializable components. Components that have data to be replicated must implement the INetworkSerializable interface and be attached to the same gameobject as ReplicatedEntity component.

    To replicate an ECS entity you create a ScriptableObject deriving from ReplicatedEntityFactory. This class is also registered in ReplicatedEntityRegistry. It contains abstract methods that must be implemented in order to create entities and classes with the serialize or deserialize component."

    https://blogs.unity3d.com/2018/07/19/spotlight-team-best-practices-guid-based-references/
     
    keeponshading likes this.
  10. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    The Team has just released FPS Sample 2.0 and updated the registery process.. hahahhaha

    [0.2.0] - 2018-11-29
    • Removed “Update Registries” button from Project Tools. Prefabs and scriptable objects that should be referenced by a registry now each have custom inspector that is used to register them.
    • Character behaviours (or abilities - naming is quite a mess atm) are now instantiated as a separate replicated entity (DefaultCharBehaviourController). This creates various sub behaviors, but all replication is handled by DefaultCharBehaviourController.
    https://github.com/Unity-Technologies/FPSSample/blob/master/CHANGELOG.md

    Oh man, that's awesome. Guess i'm updating stuff tonight.

    Cheers
    Micah
     
  11. MasonEntrican

    MasonEntrican

    Joined:
    Sep 11, 2013
    Posts:
    8
    Dude right I was just looking at this lol. Thank you for the ReplicatedEntity info I was missing that completely! Will report back once I get some more time to dive in.