Making a new weapon.

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:

  • Created a new ItemTypeDefinition and called it “Item_Assault_Light”.

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

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

  • 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)

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

  • Dragged it over in “Item_Assault_Light” asset file.

  • I used an existing secondary ability.

  • The Item is registered correctly.

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

*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)*

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

  2. 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

1 Like

Hi Toldam,

So the solution was pretty "simple". I'm new to Unity so I keep forgetting to use the framework provided to us and I focus to much on the code. The missing link was the prefabs in Unity and that's why I wasn't able to find it.

I made another guide:
https://docs.google.com/document/d/1K3xRyTN4AnUifq1-6ZYfWLvQG_E3bPkp-6YodgQdPvk/edit#heading=h.jfy26ixew03t

Hopefully it can save some headaches

Have fun

Toldam \o/

4 Likes

[quote=“Toldam”, post:2, topic: 733195]
Hi Toldam,

So the solution was pretty “simple”. I’m new to Unity so I keep forgetting to use the framework provided to us and I focus to much on the code. The missing link was the prefabs in Unity and that’s why I wasn’t able to find it.

I made another guide:
https://docs.google.com/document/d/1K3xRyTN4AnUifq1-6ZYfWLvQG_E3bPkp-6YodgQdPvk/edit#heading=h.jfy26ixew03t

Hopefully it can save some headaches

Have fun

Toldam \o/
[/quote]
share the doc you made, lol =)

It should work now. thanks for the reminder.

1 Like

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?

4398253--400147--notitle.png

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.

[quote=“Toldam”, post:6, topic: 733195]
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.
[/quote]

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

[quote=“Journeythedev”, post:7, topic: 733195]
Is it possible to update the guides? The project has changed a little.
[/quote]

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 :slight_smile:

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

https://learn.unity.com/tutorial/fps-mod-set-up-a-new-burst-rifle-weapon

[quote=“Jairus5”, post:9, topic: 733195]
https://learn.unity.com/tutorial/fps-mod-set-up-a-new-burst-rifle-weapon
[/quote]
That’s for a very different project as far as I’m aware that doesn’t use any of the ECS / DOTS stuff.