Issues with FirstPersonObjects rifle vs pistol

msm

New member
Hi,

I'm just experimenting setting up my own character. Following the setup guide I created my own character with the assault rifle as demonstrated. That worked fine. But once I try and add a second weapon, a pistol, the assault rifle is still displayed when I have the pistol equipped.

The setup is that the assault rifle is under FirstPersonObects->NolanFirstPersonArms, and the pistol is under FirstPersonObejcts->NolanFirstPersonRightArms
Both of these display when the pistol is equipped. The pistol works fine, it fires and the assault rifle does not, it is just the display that is wrong. I'm just not sure what Im doing wrong. I've read the docs and compared against the demo's Nolan character, I am not spotting the difference.

At first, I thought my solution was to disable the FirstPersonObjects children by default. That seemed to work, the proper one was automatically enabled when switching between assault rifle and pistol. Then I tried adding a second alternate pistol weapon (different ItemType). Now I am running into an issue, upon equipping a weapon, that the ChildAnimatorMonitor methods are being called before it's Awake() method is called, resulting in some NullRefs.

Attached is just the basic gameobject hierarchy, it is the same as the demo Nolan character. Can anyone help shed light on what I'm doing wrong?

Thanks
 

Attachments

Justin

Administrator
Staff member
The pistol is setup a little differently because it supports dual wielding with independent arms. Under NoalnFirstPersonArms there are four meshes for the left/right arm and its armor. On those GameObjects you'll see the Object Activator component and this is the component that deactivates the combined arms when the pistol is equipped.
 

msm

New member
hi, thanks for the help. I'm trying that, but still experience the same issue. This happens whether I pickup the item, or equip it as part of the default layout, the assault rifle is always shown, though it is not in the inventory. All the gameobjects are defaulting to active/enabled, Im not sure if that is correct, but that is what the demo Nolan character is set up like

For the pistol Item's FirstPersonPerspectiveItem, the Additional Control Objects is set to NolanFirstPersonArms, and looking at the FirstPersonObjects.cs script, I can see that it is intended that gets activated. The demo Nolan character is set up this way. So, it seems Im missing something that hides/disables the weapons under NolanFirstPersonArms, or something that puts the arms in the correct state when the pistol is equipped?
 
Last edited:

Justin

Administrator
Staff member
What exactly is the problem? The Object Activator component will deactivate the unused arms so if that's the issue then you'll want to make sure you have a state triggering it.
 

msm

New member
I believe this is the issue. My character has only an Assault Rifle parented by NolanFirstPersonArms, and a Pistol parented by NolanFirstPersonRightArms.

The FirstPersonPerspectiveItem script is deeming these as "independent", since no other items share these same parents, thus only disables the parent NolanFirstPersonArms or NolanFirstPersonRightArms object, not the item's VisibleItem object itself (AssaultRifle or Pistol game objects).

So, when Pistol is equipped the NolanFirstPersonRightArms are enabled, as well as NolanFirstPersonArms because it is listed under AdditionalControlObjects (this is how demo Nolan is set up, Im not sure why, Im guessing for some animations?)
Since the Assault Rifle visible object was never disabled in the first place, it is now visible.

So, I've fixed it for now by adding a ObjectActivator component to the visible AssaultRifle object to disable it for state "Pistol"... but Im not sure if that is the best solution. Or, if NolanFirstPersonArms is not needed as an AdditionalControlObject for the pistol item, that could be removed from there
 
Top