Start with weapons in holster?

Mattis

Active member
For somereason my Assaultrifle isnt in holster when the game starts, even if I have a Item Set 0 with revolver, he have the revolver in hand, and also the rifle (the rifle isnt shooting when I shoot with the revolver)...To get the rifle in holster, I need to equip it.. then it snaps to holster and he takes it , and when I holster it again everything is normal.....?


Other question: To get the character to start with nothing, I should make item slot 0 only body? so he can kick and punch?
 
If the revolver is in your default inventory and there's no empty item set, then I believe it'll just be equipped by default. So you'd need to add an empty item set, or as you suggest add the Body to the character's default inventory, and add a Body item set.
 
When you start the game, which Item Set is activated by default? And what's in your default inventory? Screenshots would be helpful.
 
These are my items, the game starts with item set 0 (body) and now the weapons should be in holster...
But they are not .
 

Attachments

  • items.png
    items.png
    63.6 KB · Views: 23
  • notholster.png
    notholster.png
    487.3 KB · Views: 26
This is not valid anymore since I realized I must make runtime pickups... How to get Hand Ik target to work with runtime? and how to make holster target work? (cant assign anything) Also, Third Person Local spawn position and rotation dosent do anything, the weapon always have the same transform when picking it up .
 
Take a look at the bottom of this page:

 
I got it to work.

Making a runtime grenade pickup i can't figure out though..?

But ik etc on the weapon is clear, also ammo pickup. What do I need to make them work online ? With pun intergration.
 
I found pun tutorial, I see runtime is the way to go both for online games and with UIS (havent bought it yet so I hope I can convert existing Runtime pickups) .. But this grenade, I can figure out how to do it .. I created the item type Grenade, item... Then I made the item istelf following the runtime pickup video.
Then I made the Grenade object for the throwable location.
And for last the pickup.
I can pick it up, it goes to the inventory, it plays throw animation.. I cant see it in hand, and he throws empty air, and sometimes I get this error :

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Items.Actions.ThrowableItem.ThrowItem () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ThrowableItem.cs:506)
Opsive.UltimateCharacterController.Items.Actions.ThrowableItem.StopItemUse () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ThrowableItem.cs:622)
Opsive.UltimateCharacterController.Character.Abilities.Items.Use.AbilityStopped (System.Boolean force) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Use.cs:866)
Opsive.UltimateCharacterController.Character.Abilities.Ability.StopAbility (System.Boolean force, System.Boolean fromController) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:692)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStopAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean force) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1440)
Opsive.UltimateCharacterController.Character.Abilities.Ability.StopAbility (System.Boolean force, System.Boolean fromController) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:687)
Opsive.UltimateCharacterController.Character.Abilities.Ability.StopAbility () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:664)
Opsive.UltimateCharacterController.Character.Abilities.Items.Use.AbilityCanStop (System.Int32 slotID) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Use.cs:716)
Opsive.Shared.Game.ScheduledEvent`1[T].Invoke () (at <52a41b32fbc54a60add8140e367dde46>:0)
Opsive.Shared.Game.SchedulerBase.Invoke (Opsive.Shared.Game.ScheduledEventBase scheduledEvent, System.Int32 index) (at <52a41b32fbc54a60add8140e367dde46>:0)
Opsive.Shared.Game.SchedulerBase.FixedUpdate () (at <52a41b32fbc54a60add8140e367dde46>:0)

And when I pickup the first grenade, I can see it fall.
And on items its theres, but it wont be seen in scene view or game... What do I dont get ?
 
Okay, theres an rigidbody on the grenade then gets putted into items. So I deleted the rigidbody.. Now it works.
 
I have the same issue as the post creator here. I start with my character who's default loaded weapon is the Body. But I also have a shotgun in my inventory but I want this item to start holstered but it wont.
Its still in the hand with the HandIK settings etc even tho the bodyItem is active in the inventory.
shotgunbug1.png

shotgunbug2.png
shotgunbug3.png
 
Your body is the top item in the Item Set Manager so that's why it will be equipped first. The shotgun is not equipped so as long as you have specified the holster under the Third Person Perspective Item then it will be set in the holster position. Make sure you are running the latest version as I remember there were some fixes related to this.
 
Your body is the top item in the Item Set Manager so that's why it will be equipped first. The shotgun is not equipped so as long as you have specified the holster under the Third Person Perspective Item then it will be set in the holster position. Make sure you are running the latest version as I remember there were some fixes related to this.
I have holster assigned and it is working properly when I just store the weapon away. But when I start the scene the weapon is equipped. I tried another weapon to see if it was the shotgun that was bugged, but it does exactly the same with the Desert eagle:

DesertEagleHolster2.PNG

I will check if I got the latest update, I believe I do tho!

EDIT: I had an update. Installed it but it didnt change anything instantly. I will try to see if I change the weapons around a bit if it will work!
 
Last edited:
I updated everything (had quite some accumulated updates on several assets). I removed the gun from inventory and added it again but the problem still remains.

The weapon gets visible in my hand but not parented under the holster when I start the game. I cant shoot with the weapon, I do my bodyItem attack with the gun in hand.

Somehow I need to tell the weapon to start in the holster when I start the game. Any suggestions on how to call that?
 
I may have found the culprit of this issue in the demo scene, not sure if it fully applies to your case, but it's to do with when the camera perspective changes (which also happens during camera initialization of the Character). Item.OnChangePerspectives calls PerspectiveItem.SetActive with active = true if the weapon is in the inventory, even if it's not actually active (equipped) at that time, causing ThirdPersonPerspectiveItem to position the visible object in the character's hand rather than holster.

A (very rough) workaround for now, until Justin can hopefully implement a more complete fix - in Item.OnChangePerspectives (line 1063):

C#:
        protected virtual void OnChangePerspectives(bool firstPersonPerspective)
        {
            // The object isn't active if it isn't equipped. OnChangePerspective will be sent to all items regardless of whether or not they are equipped.
            var isActive = m_ActivePerspectiveItem != null && m_ActivePerspectiveItem.IsActive();
            if (firstPersonPerspective) {
#if FIRST_PERSON_CONTROLLER
                m_ActivePerspectiveItem = m_FirstPersonPerspectiveItem;
#endif
            } else {
                m_ActivePerspectiveItem = m_ThirdPersonPerspectiveItem;
            }
            if (isActive) {
                var hasItem = m_Inventory.GetItemIdentifierAmount(m_ItemIdentifier) > 0;
                var active = m_Inventory.GetActiveItem(0).ItemIdentifier == m_ItemIdentifier; // <-- NEW LINE
                m_ActivePerspectiveItem.SetActive(active, hasItem); // <-- CHANGED LINE (changed first argument to `active`)
            }
        }

This fix assumes that the item is in slot 0. I'll pass this on to Justin though to hopefully get a more general fix.
 
Thanks @Andrew! Here's a proper fix within that same method:

Code:
            if (isActive) {
                var hasItem = m_Inventory.GetItemIdentifierAmount(m_ItemIdentifier) > 0;
                var active = m_Inventory.GetActiveItem(m_SlotID)?.ItemIdentifier == m_ItemIdentifier;
                m_ActivePerspectiveItem.SetActive(active, hasItem);
            }
 
Thanks @Andrew! Here's a proper fix within that same method:

Code:
            if (isActive) {
                var hasItem = m_Inventory.GetItemIdentifierAmount(m_ItemIdentifier) > 0;
                var active = m_Inventory.GetActiveItem(m_SlotID)?.ItemIdentifier == m_ItemIdentifier;
                m_ActivePerspectiveItem.SetActive(active, hasItem);
            }
I may have found the culprit of this issue in the demo scene, not sure if it fully applies to your case, but it's to do with when the camera perspective changes (which also happens during camera initialization of the Character). Item.OnChangePerspectives calls PerspectiveItem.SetActive with active = true if the weapon is in the inventory, even if it's not actually active (equipped) at that time, causing ThirdPersonPerspectiveItem to position the visible object in the character's hand rather than holster.

A (very rough) workaround for now, until Justin can hopefully implement a more complete fix - in Item.OnChangePerspectives (line 1063):

C#:
        protected virtual void OnChangePerspectives(bool firstPersonPerspective)
        {
            // The object isn't active if it isn't equipped. OnChangePerspective will be sent to all items regardless of whether or not they are equipped.
            var isActive = m_ActivePerspectiveItem != null && m_ActivePerspectiveItem.IsActive();
            if (firstPersonPerspective) {
#if FIRST_PERSON_CONTROLLER
                m_ActivePerspectiveItem = m_FirstPersonPerspectiveItem;
#endif
            } else {
                m_ActivePerspectiveItem = m_ThirdPersonPerspectiveItem;
            }
            if (isActive) {
                var hasItem = m_Inventory.GetItemIdentifierAmount(m_ItemIdentifier) > 0;
                var active = m_Inventory.GetActiveItem(0).ItemIdentifier == m_ItemIdentifier; // <-- NEW LINE
                m_ActivePerspectiveItem.SetActive(active, hasItem); // <-- CHANGED LINE (changed first argument to `active`)
            }
        }

This fix assumes that the item is in slot 0. I'll pass this on to Justin though to hopefully get a more general fix.

Works perfectly! Well done guys and thanks a lot for fixing this!
 
I have the same or similar issue yet the code change suggested by @Justin / @Andrew doesn't seem to do anything for me.

I can't get my item to start holstered. However, equipping and unequipping it holsters it correctly, so the issue is strictly about getting the right state at startup.

After startup, the item is under the third person items holder object in the character's hand, disabled. After equip+unequip it is under the holster gameobject, enabled, which I believe is correct, but why isn't it there after startup? I have no item set set to Default and the character is spawning with no item set selected, so I figure they should all be holstered.

Version is 2.4.3.
 
Last edited:
Top