Weapon Customization Guidelines?

Juneav

New member
Hello!
Been wondering how to create some sort of weapon customization using the character item...
My goal is to have one type of weapon that can be customized in runtime by the player, for this I have a weapon model that I have setup following the third person character item tutorial, so far so good, now I want to have some script on it that can enable or disable some weapon parts like scopes, grips and barrels, when the player dopes this the weapon shootable properties should change as well, such as the fire rate, the recoil effect and some states for the zoom... can this be done? I have tried to change some of the those modifying the recoil properties in runtime but I get an Argument exception error, then I tried creating states and activating them also in runtime but I get the same error, so I am a bit lost. I saw on the docs that I could use some binding properties that change properties using variables, but I have no clue on how to achieve this. I can control on my scripts which variables should be updated when activating some parts of the model, but how can I have these variables actually change the wepon properties?

Im attaching some SSs so you can have a visual idea of what I am trying to achieve.

Also, I have an asset from Knife that can shoot different types of sci fy bullets like blasters, lasers, rockets, etc. I have succestfully integrated these in the default character item and fire them manually whenever the OnUseItem event is fired, the thing with this is that behind the curtains the standard character item is being used, the default bullet is being fired, the recoils and everything else... is there a way in that I can quickly convert the Knife effects/assets to those in Opsive? Because it would be really a lot to set, also to manage the collisions and everything, do you think its a good idea to keep "faking" the character item system?

Thanks a lot!
 

Attachments

  • Captura de pantalla 2024-04-12 150949.jpg
    Captura de pantalla 2024-04-12 150949.jpg
    439.6 KB · Views: 4
  • Captura de pantalla 2024-04-12 150851.jpg
    Captura de pantalla 2024-04-12 150851.jpg
    393.2 KB · Views: 4
can this be done?
Yes, it definitely can. You can either have all of the modules added at runtime and then control when they are active with the state system (which is what we do in the demo scene), or you can add and remove the modules at runtime. For this take a look at the UMA integration for an example. The first option is probably more performant compared to the second as long as you have a fixed set of modules that you want to allow for.

is there a way in that I can quickly convert the Knife effects/assets to those in Opsive?
You can add any number of item actions to the item. So for example you can have a Shootable Action and Melee Action on the same item. We do this in the demo scene on the shootable weapons allowing you to melee with the weapon.
 
Alright!
Thanks a lot, I have started my setup with your recommendations, so far I have been able to create a "root" item that I can configure in runtime using only the usable action and the generic item effects to fire any type of my custom weapons effect ( this is the asset: https://assetstore.unity.com/packages/vfx/particles/pro-effects-sci-fi-shooter-fx-176115 ).

But now, here's a couple of new questions I have:

1. How can I detect the custom bullet collisions on my opsive characters?
I have setup an AI character with all the basic components, one of those is the Health component, and I have set up the head collider on it.
If I hit it with a "regular" opsive weapon/projectile the collision is detected correctly and I can trigger instant dead for headshots, but of course, if I hit it with my custom projectile (from Knife's asset) I can only detect collision on such projectiles, which would be overkill when I have hundreds of projectiles spawned. I want to be able to use opsive' character collision detection using my custom projectiles, so the main question is, what component should I add to my custom projectiles in order to detect headshots on my AI character? I already have a way to add damage variables to my projectiles.

And...

2. How can I add some recoil effect to my character while firing my custom weapons?
Should I use the spring system? Does it affect IK? Do you have some examples on this?

BTW, I will be enabling states for some weapons parts dinamically as you suggested ;)

Thanks a lot! Hope you can help me! :)
 
what component should I add to my custom projectiles in order to detect headshots on my AI character?
That is determined by calling Health.Damage on the character: https://opsive.com/support/documentation/ultimate-character-controller/attributes/health/. Since you are using a separate system you will need to call this method manually.

2. How can I add some recoil effect to my character while firing my custom weapons?
Should I use the spring system? Does it affect IK? Do you have some examples on this?
There is a recoil module which will apply a change in the camera rotation as well as IK for third person. All of the shootable weapons use this module so you can take a look at that.
 
Top