Crosshair Monitor error / Look Source?

Vlaxep

Active member
Howdy,

I've spent days trying to fix a look source error, which after removing a bunch of other errors has gone away.

Now I'm having issues with the CrosshairMonitor - I'm getting the following error

NullReferenceException: Object reference not set to an instance of an object Opsive.UltimateCharacterController.UI.CrosshairsMonitor.Update () (at Assets/Opsive/UltimateCharacterController/Scripts/UI/CrosshairsMonitor.cs:171) That line 171 in the script is here: var crosshairsRay = m_Camera.ScreenPointToRay(m_CenterRectTransform.position); It's broken my character when I switch my Prefab to this newPrefab and it instantiates with no weapons equipped and I can't change between all my weapons....

So this is all coming about when I perform a 'Prefab Switch' when player chooses a different character.

First character spawns in fine, no issues.

I then destroy the prefab and instantiate the new one. So from here I can get 2 distinct results from trying to fix that error.....

For the property 'Character' in CrosshairsMonitor, if I set it to the CharacterRoot of the Prefab I get the following

- The error only shows once, but CrosshairsMonitor disables itself and never sets the default crosshair or item specific crosshair

For the property 'Character in CrosshairsMonitor, if I leave it blank I get the following

- The error repeats 999+ breaks all my character's weapons and items (nothing equips and can't cycle items)


The line 171 in the error is:

var crosshairsRay = m_Camera.ScreenPointToRay(m_CenterRectTransform.position);


No bloody idea what to do with that, or why it's breaking things so bad lol.

see attached my CrosshairsMonitor component
 

Attachments

  • image_2021-02-23_140110.png
    image_2021-02-23_140110.png
    85.1 KB · Views: 9
For the property 'Character' in CrosshairsMonitor, if I set it to the CharacterRoot of the Prefab I get the following
You should not set the character field to a prefab. It should be of the instantiated character.
 
Hi Justin, I realised this was my mistake in the first place. I was having issues a while ago when adding networked players, so I placed this within character prefab and was disabling things that needed to remain active.

I've placed it back in the scene and adjusted what components I'm deactivating.
 
Top