Changing Canvas from "Screenspace - Overlay" to "Screenspace - Camera" make character unable to fire or change weapons

TrungDong

Member
*This bug also appeared on the Demo scene.
For some reasons, I need the canvas which contains Health Flash, Damage Indicators, Crosshairs, etc have to be changed from "Screenspace - Overlay" to "Screenspace - Camera".
But when I did so, my character is unable to fire.
After a quick debugging, the cause is FPSArms's animator seems to be stuck at Base Layer > Aim Idle's Aim Idle animations state, animator's "Slot0ItemStateIndex" always be 0.
Changing back the canvas render mode will resolve this bug.

So, to make sure what element has caused this strange behavior, I created a new "Screenspace - Camera" canvas, named "CanvasUI", and moved one by one also tested one by one the child object of "Screenspace - Overlay" Canvas to CanvasUI.
Everything is alright, except Crosshairs.

Summary:
- If Crosshairs' parent canvas's render mode is "Screenspace - Overlay", there is no problem.
- If Crosshairs' parent canvas's render mode is "Screenspace - Camera", the animator will be stuck, weapons are unable to use or change.


Anyone know why? And how to fix this bug? I just want to change the canvas render mode!
 

Attachments

  • Screen Shot 2020-11-29 at 11.25.30 PM.png
    Screen Shot 2020-11-29 at 11.25.30 PM.png
    59.9 KB · Views: 0
I just tested in a fresh demo scene and couldn't reproduce this bug. I started up the scene, then switched that monitors canvas to the Camera screen space. I was able to continue using items as normal. What version of UCC are you using?
 
I don't know how to see the version number. I checked the ReadMe.txt and Documentation.pdf but found nothing.
But I'm sure this version is from late 2019.
 
By the way, just "switched that monitors canvas to the Camera screen space" will not reproduce this bug. You have to assign a camera to that canvas.
 
Yes, I did that too.

You can check the version number in the Opsive manager (tools -> Opsive -> [your controller] -> Main Manager). The version will be displayed at the bottom of the manager window.
 
I have found the solution:
Commenting out (or delete) the line " m_CameraController.SetCrosshairs(transform);" in " OnAttachCharacter()" of CrosshairsMonitor.cs will solve the bug "animator is stuck, player unable to fire or to change the weapon".

But if you do that, the crosshairs will not change it's color to red when you point your gun at the enemy. To fix this new problem:
- Create a new variable like: [SerializeField] protected Transform _trfScreenspaceOverlayCrosshair;
- Create a Screenspace - Overlay canvas, create an empty object at the center of the screen, drag that empty object to _trfScreenspaceOverlayCrosshair;
- In CrosshairsMonitor.cs, Awake(): change "m_CenterRectTransform = m_CenterCrosshairsImage.GetComponent<RectTransform>();" to " m_CenterRectTransform = _trfScreenspaceOverlayCrosshair.GetComponent<RectTransform>();"

Then everything will be fine.
 
Top