Integrating Realistic Snipers and Ballistics

niltheory

New member
I'm currently integrating the Realistic Sniper and Ballistics System asset inside of Opsive with the usage case still needing to use the Opsive-based projectiles for items that aren't chambered ammunition. I've created a script called BallisticsHelper which inherits from ShootableAction since when I added the code to ShootableAction.cs the only thing that would show up in the inspector is the first boolean variable. It took a couple hours and migrating the initial prefab, I had to explicitly set specific references and make another version of the prefab using the Migration Manager.

Here's what initially works but needs more added to it because it otherwise works but shoots an unlimited amount of times regardless of the checking the clip and seeing how much ammo is left:

1689358519339.png

When the appropriate bool, isUsingAmmunition, is toggled, it will switch to the RSB system
So, far this is what I have but it's not perfect, there are some initial errors that throw into the console but I'm testing out different methods, quite literally:

1689358243150.png
I've noted the attempts that would cause a stack overflow to, I've currently nested another if, else statement where I'm trying to manually get what would normal happen after pressing use by using, the ShootableAction use and reload flow chart.
1689358695257.png


I'm thinking of replicating a little of what happens next but I'm not quite sure how to handle public virtual getters / setters:
1689358926732.png
What I do know is that I want to still use the data that's entered inside of the Modules in ShootableAction and then return, then edit that as if I was using the standard script. So, then, if alike when previewing the data to fire-- it will check to see if the ClipRemainingCount[index] is not equal to zero it will be able to be fired again, otherwise, it will be allowed to be reloaded. With that said, this is my next step to making it functional as per normal then, I can worry about the heavy reverb and delayed fire sound when the item is used.




The other occurring problem that caused issues initially was with this which I fixed by changing the OnAim method into a public override:
1689359178452.png

However it now continues throws an input error into the console, which is this:
Button "" is not setup. Please create a button mapping within the Unity Input Manager.
UnityEngine.Debug:LogError (object)
Opsive.Shared.Input.StandaloneInput:GetButton (string,Opsive.Shared.Input.InputBase/ButtonAction) (at Assets/Opsive/Shared/Input/StandaloneInput.cs:36)
Opsive.Shared.Input.UnityInput:GetButtonInternal (string) (at Assets/Opsive/Shared/Input/UnityInput.cs:223)
Opsive.Shared.Input.PlayerInput:GetButton (string) (at Assets/Opsive/Shared/Input/PlayerInput.cs:215)
Opsive.UltimateCharacterController.Character.Abilities.Ability:CanInputStartAbility (Opsive.Shared.Input.IPlayerInput) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:329)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler:UpdateAbilityInput (Opsive.UltimateCharacterController.Character.Abilities.Ability[]) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:132)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler:UpdateAbilityInput () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:100)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler:Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:75)
 
Instead of inheriting ShootableAction I would instead create a new module. The module system is designed to be extremely flexible to account for cases like this. With that said, it's really hard for me to follow along with that code without seeing the integration asset. I can add this to my integration request list. I do think though that using the modular item system is the way to go.

Button "" is not setup. Please create a button mapping within the Unity Input Manager.
It looks like one of your abilities is set to a button input but you don't have any input setup for that ability.
 
Instead of inheriting ShootableAction I would instead create a new module. The module system is designed to be extremely flexible to account for cases like this. With that said, it's really hard for me to follow along with that code without seeing the integration asset. I can add this to my integration request list. I do think though that using the modular item system is the way to go. The script I added in is my most recent attempt.

This was just a way easier for me to set up:
1689381409992.png

It looks like one of your abilities is set to a button input but you don't have any input setup for that ability.


Okay! I understand what you mean, I just needed to get something working now so I can start prototyping and I did somewhat get it to work to start doing exactly that.

I'll start creating a new module for something better in the meanwhile.
 

Attachments

  • BallisticsHelper.cs
    3.7 KB · Views: 2
Last edited:
Okay. So, I've created an Action Module, when it's selected. It correctly shoots the RSB bullet points and the DynamicScope script switches the caliber type based on which weapon is found that has module id[2], the fire reference and communicates with the RealisticShooter Shooter Module and the instance of the SniperAndBallisticsSystem.

Now the final issue is more how I'm trying to get the bullet data to relay the information to the ProjectileBase, have it pass through and correctly collide and deal with the damage as with the normal projectile in ProjectileShooter module.

This is the BulletPointRelay.cs script, so in it I've set some of the variables manually that would normally be set in the inspector inside of Awake. The idea I had was... for better imagery, the projectile would be wrapped around the rsb bullet, it'll pass through with the sphere collider and functionally work the same way-- deal damage to the target-- as it just needs to follow the rsb bullets arc.

1693546115934.png



Edit: I've successfully integrated it in a functional capacity, albeit with some tweaks that'll need to be done. I removed the BulletPointRelay script that I made. Then figured out how to create and assign the assembly definition file. Included, "Opsive.Shared" and "Opsive.UltimateCharacterController" to the RSBRuntime.asmdef.

From then on it was just making sure the assigned logic works.
 

Attachments

  • DynamicScope.cs
    6.1 KB · Views: 2
  • RealisticShooter.cs
    15.4 KB · Views: 2
Last edited:
Top