Shield Collider Script asking for object reference

jayen71

New member
Hello,

I'm trying to set up my character with an Axe that can block or parry. I followed the item pickup video to set up the item similar to what the Katana looks like in the demo. I attached the Shield Collider script to the 3rd person prefab so when the Axe is picked up the 3rd person prefab has the correct component. ( I'm using the Katana as a template and it looks like it was created the same way) The item itself has the Shield script attached.

The issue is that the shield collider script on the 3rd person Axe is asking for an object reference and after one swing will enable the collider on the 3rd person Axe. The object reference is specific to a shield object here on the character. It looks like it's asking for a shield object reference but the item attaches and is part of the parent.

1579539917326.png

I don't know what it's trying to reference on the character controller. When I look at Nolan in the demo scene, he will parry with the sword or katana but I cannot seem to replicate it.

Any pointers?
 
Is the code that you posted causing an exception? That is used to get the character to be able to register for a perspective change. Which shield reference are you referring to?
 
The Shield reference is the Shield script on the Item I think. In this case, it's the Shield script on the Axe.


Line 37 - starts with m_Character, is throwing the null reference exception. When I pick up the Axe the console reports a null reference exception and the collider isn't enabled. It appears in the Player's hands and I can swing with it but after a swing, it turns the collider on.

I get the NullReferenceException as I pick the Axe up. And the EventHandler error after I stop play.

1579574580981.png


I tried a different way and copied the set up on the Sword in the Demo Scene and applied it to the Axe.
1579576447290.png
On start, the box collider is turned off on my Axe while it stays active on the Demo Sword.

The only difference is I'm not using the 1st person Melee properties or 1st person perspective Item scripts so I removed them. I also created the Axe Item type and applied the changes to the Axe Item script component. Below just shows the Shield script on both items. Settings are the same.
1579576599400.png

But on load or pick up, depending on how I have the weapon setup, I get the null reference.


I know there is an option on either the item or the character I missed but I don't know what it is. Everything looks generally the same. I can bring in the katana to a new scene with a custom Character using the same Item types as the Demo scene but it gives me the same error.
 
Ahh, I see the issue now. When the shield is built it should set a reference to the Shield Collider automatically and you don't need to manually assign it. Did you use the Item Builder to add the shield? One way to fix an already created item would be to modify the ShieldCollider script and remove the [HideInInspector] attribute from the m_Shield reference. You can then assign the shield component and add the [HideInInspector] attribute back.
 
I knew I was missing something in the setup. I didn't realize I add an action like that to an existing item. Thank you!
 
Top