Control over weapon fire

Silver100

Member
Hope you can help on this as this is the main thing preventing me from having a range of weapons;

I'm thinking of expanding my range of weapons I have in my game & most importantly to maintain & make sure the player can never fire unequipped. Because of my basic code skills I have kept my game simple implementing my own methods to disable fire if unequipped.
I have my own bullet method. To disable is simply done when the sword becomes active, the Swords collider disables the fire method. The sword must be the last item for this to be effective. Works well and I understand as its simple.
The issue is, unlike sword and rifle, pistol for some reason has to cycle through the unequip animation before moving to next item
This means player can fire unequipped at this point. Can I disable the pistol unequip animation? This doesn't happen with just 2 weapons as sword will directly equip straight to rifle no unequip phase here at all.
Just trying to either arrange or code a simple quick method that has full control as to when my weapons should fire and when they should not. I have attempted a weapon script with booleans and on trigger enter/exit for each weapon held but couldn't get it to work. I have tried block/state pre-sets. Also tried a counter integar method after 2 button presses but this seemed a one way process where it would not re-set.
I also experimented duplicating rifle and anim (changing to anim ID 2) and just changing the visual mesh replacing with pistol hoping I could some how just switch effortlessly switch between the 2 and skip the equip animations but couldn't get it to work well. Is there a speedy simple solution to prevent fire on an unequipped player?
 
Last edited:
If you have to cycle through the unequip animation then it sounds like the pistol isn't fully equipped. If you have replaced the animations make sure you've added the appropriate equip events. From a code perspective the pistol is the same thing as your sword and rifle.
 
Thanks,

The animations were not replaced, I re-assigned the pistol carefully set up just like the other items, just to check and be certain. I think its just the unequipped slot, it happens with all other new items beyond 2?

Really I just need access and control how to move the order position of the unequipped slot. In the video below you can seen the unequipped slot occurs after pistol just where is should not happen. Seems like it should be a simple to resolve just change the order somewhere but nothing can alter this?
For some reason no matter what load out order I can not move the unequipped slot. It's as if its perhaps assigned to the last item created?
I can arrange which item is loadout but I cant select where unequipped event slot should be?

I'm happy I have got this far but would be incredible if I could get this working as I would have full control over adding more weapons with no issues. Just feel I'm at a road block if I want to expand on my simple workaround method.

Some how I need to simply move the players unequipped stage to just after sword not pistol, it needs to go direct to sword where the sword 100% reliably disables the fire method. If this is achieved I can expand on, and have more weapons.
Checked item set rules too thought there may be something there to help. Set all wait for animation set to 0.

This would be an ideal order of equip events;

Rifle - directly to;
Pistol - directly to;
Sword (Disable fire method)
Unequip** always needs to be here

Player must be equipped through the cycle of weapons rifle direct into to pistol to sword until sword then unequips

Not;

Rifle directly to;
Pistol directly to; (no unequip)
Unequip*** disrupts otherwise perfect working cycle suddenly player is able to fire unequipped.
Other ideas include change animator ID in run time somehow say Anim ID 1 to 2 and replace the visual mesh keeping attached not been able to achieve this attempting to change ID anim value on character Item script

 
Last edited:
There isn't anything special about have a third item versus a second item, first item, etc. You should check the inventory inspector to ensure the third item is bold meaning that it is equipped. If it's not bold then it is related to how you are equipping or unequipping the item. I think that you have a lot of custom logic with this and that may be the cause.

As always, if you can reproduce it within the demo scene then I will have a better idea of why it is happening.
 
Yes your right it's nothing to do with items but more my actual set up. All looks good in the inspector is bold played with (minimised focused view so thats all good) I'm using equip next item direct, no unequip until last item so definitely made some changes .
Just re-did creating some items from fresh and checked it appears in my set up any new item created becomes the final unequip phase regardless to loadout order which is fine just need to move that to the last unequip phase to sword . I re- built rocket launcher, pistol sword and rifle to confirm. I'm using a fair bit of custom logic in the collider trigger sense, and have a unique set up that suits my game and skill level. In the Demo the behaviour is totally different the player unequips / equips the weapons.
Seems like it should be easy to move unequipped stage but isn't just thought there could be a custom setting much like default load out or equip / unequip order or dragging the items.
Also checked the 'Opsive main manager, item types, items list' tried to re-arrange. The item set slots become visible when pressing play but not otherwise just wondering if there may be something here too
 
Last edited:
All fixed & working really well. By creating a new Melee item it arranges the unequip slot where I needed it to be. (Opsive main manager, items) Basically the last item created becomes the unequipped item. I'm just mudding through and there are way better methods sticking with the documents, but it works for me and hopefully I can improve my skills to use more Opsive methods but now I can expand on.

On each item I have arranged with OnTrigger, set active type code, in the order;

Rifle to Pistol (disables Rifle), Rocket launcher (disables Rifle) then finally sword unequips at the end, (disables Rocket launcher fire). Just need to add more effects and variation to damage given

.
 
Last edited:
Top