Search Unity

Making a new weapon.

Discussion in 'FPS.Sample Game' started by Toldam, Feb 22, 2019.

  1. Toldam

    Toldam

    Joined:
    Feb 4, 2019
    Posts:
    9
    Hi FPS.Sample Community o/.

    Here we go again. I've learned how to change the prefabs on our existing two weapons but now I want to try to separate the weapons abilities from each other by creating new scripts. The issue I'm having is that I have a hard time figuring out how everything is connected together in this amazing project.


    What I already did:
    1. Created a new ItemTypeDefinition and called it “Item_Assault_Light”.

    2. Used a working existing prefab for Client and 1P.

    3. Created a new Script for “Ability Prim Fire” and called it “Ability_Assault_Light”

    4. I copied everything from the “Ability_AutoRifle” Script and pasted into my new script. I did of cause make sure to change all necessary names and references (I hope)(https://gist.github.com/NichlasToldam/42aec9be5b9e1c762898b179a9e96aba)

    5. Created a new ability with the new “Ability_Assault_Light” script and called it “Ability_Assault_Light_Test”.

    6. Dragged it over in “Item_Assault_Light” asset file.

    7. I used an existing secondary ability.

    8. The Item is registered correctly.

    9. When I switch to the character with the new Ability I get the following error message:

    [I]ApplicationException: GAME ASSERT FAILED : AbilityController does not own a Ability_AutoRifle ability (TerraformerWeaponA)
    GameDebug.Assert (System.Boolean condition, System.String msg) (at Assets/Scripts/Core/GameDebug.cs:126)
    UpdateTerraformerWeaponA.Update (GameTime time, TerraformerWeaponA weapon, Character character) (at Assets/Scripts/Game/Modules/Item/TerraformerWeaponA/TerraformerWeaponA.cs:78)
    UpdateTerraformerWeaponA.Update (Unity.Entities.Entity entity, CharPresentation charPresentation, TerraformerWeaponA weapon) (at Assets/Scripts/Game/Modules/Item/TerraformerWeaponA/TerraformerWeaponA.cs:70)
    BaseComponentSystem`2[T1,T2].OnUpdate () (at Assets/Scripts/ECS/BaseComponentDataSystem.cs:92)
    Unity.Entities.ComponentSystem.InternalUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.18/Unity.Entities/ComponentSystem.cs:374)
    Unity.Entities.ScriptBehaviourManager.Update () (at Library/PackageCache/com.unity.entities@0.0.12-preview.18/Unity.Entities/ScriptBehaviourManager.cs:77)
    ItemModule.LateUpdate () (at Assets/Scripts/Game/Modules/Item/ItemModule.cs:48)
    PreviewGameLoop.LateUpdate () (at Assets/Scripts/Game/Main/PreviewGameLoop.cs:424)
    Game.LateUpdate () (at Assets/Scripts/Game/Main/Game.cs:659)[/I]


    10. I created a new script called AssaultLightWeaponA.cs and based it on TerraformerWeaponA’s script. (https://gist.github.com/NichlasToldam/446eaef1a4ce5d400a45a385784a48c1).

    11. I created a new script called AssaultLightUI.cs and based it on AssaultLightUI.cs
    (https://gist.github.com/NichlasToldam/baf1be9cc4c2ed64f5161e689a630d77).

    So here’s my question. How do I get the application to read AssaultLightWeaponA rather than TerraformerWeaponA’s script when the character is being loaded? I’ve tried to find all the dependencies with no luck.


    Have a good weekend

    Toldam
     
    AggressiveMastery likes this.
  2. Toldam

    Toldam

    Joined:
    Feb 4, 2019
    Posts:
    9
  3. minibotan

    minibotan

    Joined:
    Oct 4, 2016
    Posts:
    15
    share the doc you made, lol =)
     
  4. Toldam

    Toldam

    Joined:
    Feb 4, 2019
    Posts:
    9
    It should work now. thanks for the reminder.
     
    Journeythedev likes this.
  5. angelolgoes13

    angelolgoes13

    Joined:
    Sep 25, 2017
    Posts:
    1
    Hey @Toldam, the "Item → TypeDefinition" option seem to have changed. It doesn't got the "Ability Prim Fire" and "Ability Sec Fire" nor the "Register" button.

    Any tips to go about this?
     

    Attached Files:

  6. Toldam

    Toldam

    Joined:
    Feb 4, 2019
    Posts:
    9
    Hey angelolgoes13,

    I'm not sure.
    You're problably using a newer version or build than us. They might have changed something in the last update. FPS Sample is a working project, and it's not easy to implement all the new features they add because it will collide with all the stuff we have modded or added. If youfinds a solution. please post it in here so we can keep helping each other.
     
  7. Journeythedev

    Journeythedev

    Joined:
    Oct 19, 2016
    Posts:
    16

    Is it possible to update the guides? The project has changed a little.
     
  8. karstenv

    karstenv

    Joined:
    Jan 12, 2014
    Posts:
    60
    Sorry no. We are still working on the old version of the FPSSample, and Toldam is no longer working on hte project as he was an intern and is now back in school :)

    But it should be possible to figure out any small changes using this guide.