Impossible to zoom in on the shot after a scene change (with don’t destroy on load)

DeeJay

New member
Hello everyone.
I apologize if the topic has been covered, but I can’t find any information about it on the forum.
I use UCC and unity3D 2021.2.5 and my character use third person perspective.
I want to make my character persist through different scenes. So I follow the example provided by the documentation (My character, my camera and my ui canvas are well in "don’t destroy on load") and it works well, with the exception of the zoom of the camera during the shooting after having changed scene once.
Indeed when I press "Fire2", the character aims but the camera does not zoom.
The unity console does not raise any errors.
However, in a scene where the zoom does not work via "fire2", I can still activate it on the camera via the inspector
Any idea how to fix it please?
Thanks in advance.
 
The zooming is controlled within the CameraControllerHandler - if you place a breakpoint on line 113 does TryZoom get called? This is where I'd start to debug.
 
So you are pressing the fire2 button? Or not? Zoom should be true if you are pressing the button.
 
Sorry for my bad english .
"fire2"is pressed, "Zoom" is to true but the camera doesn't zoom.
So it detects that I'm pressing the touch, but the camera doesnt zoom at all.
It only occurs once I change scene.
 
I have to re import my project and now it works fine.
Sorry to disturb you and thank you for the support .
 
I am having this issue. I am loading my character from scene 1 to scene 2 and the fire 2 zoom isnt working. When I start in scene 1 it works. If I load scene 2 it quits working. Scroll wheel zoom works and when I check the manual zoom button in the inspector it works.
 
You can set a breakpoint and step through the code to determine where it exists early.
 
I put in debug lines in the try zoom function and none of them trigger. This is the right click zoom. The scroll wheel zoom works fine. Other ideas of an area this is breaking in?
 
If TryZoom doesn't trigger then try inserting the breakpoint one higher level - CameraControllerHandler.Update. The zoom bool should return false when the button is pressed.
 
Hopefully Im doing this right.
private void Update()
{
bool zoom;
if (m_ContinuousZoom) {
Debug.Log("Button Pressed");
zoom = m_PlayerInput.GetButton(m_ZoomInputName);
} else {
zoom = m_PlayerInput.GetButtonDown(m_ZoomInputName) ? !m_CameraController.ZoomInput : m_CameraController.ZoomInput;
Debug.Log("Else Button Pressed");
}

if (zoom != m_CameraController.ZoomInput) {
Debug.Log("TryZoom");
m_CameraController.TryZoom(zoom);
}
It constantly goes to log the Button Pressed. Then when I right click it triggers TryZoom Debug.
So comparing my scene 1 to scene 2 the debug messages are the same there.
 
Last edited:
Something else Justin, this error started happening when I try to create a new state a couple months back.
UnityException: Creating asset at path Assets//Assets/Opsive/UltimateCharacterController/Grow.asset failed.
Opsive.Shared.Editor.Inspectors.StateSystem.StateInspector.CreatePreset (System.Object target, Opsive.Shared.StateSystem.State[] states, UnityEditorInternal.ReorderableList reorderableList, System.String selectedIndexKey) (at Assets/Opsive/Shared/Editor/Inspectors/StateSystem/StateInspector.cs:418)
Opsive.UltimateCharacterController.Editor.Inspectors.Camera.CameraControllerInspector.CreateViewTypePreset () (at Assets/Opsive/UltimateCharacterController/Editor/Inspectors/Camera/CameraControllerInspector.cs:452)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at <5f40cdb07bd44d76a23dad985a4ec283>:0)
 
Something else, in another script attached to the player there is a crawl preset state that isnt turning on either. So the entire state system is breaking down on this scene? There are no errors or any warnings, it just doesnt work. :/
 
So it is getting to TryZoom? It's within TryZoom that you should insert the breakpoint and track down where it is ending early.
Something else Justin, this error started happening when I try to create a new state a couple months back.
UnityException: Creating asset at path Assets//Assets/Opsive/UltimateCharacterController/Grow.asset failed.
That path is wrong. Ensure you are trying to save the state in the same project that you are working in. This is unrelated to zooming.
 
Yeah the tryzoom seems to be working fine and returning fine. It seems all states are breaking down when I do a Async load on two levels and move my character to the next level. At that point the state system just doesnt work. No errors, nothing. I guess I need to check it in a build.
And on the saving the path yes I realize that path is wrong but when I try to create a new state that is where opsive and unity go to. Ive tried setting the path to just my assets folder but it adds Assets// in front of any folder in my project. Suggestions how to fix that?
 
For the state system make sure you are marking the StateManager as DontDestroyOnLoad and are not instantiating a second copy of it.

Ive tried setting the path to just my assets folder but it adds Assets// in front of any folder in my project. Suggestions how to fix that?
I haven't seen this before - can you tell me how to reproduce it within a fresh project?
 
Thank you Justin! Yeah I moved the game manager to my character object so it moves with her to level 2 and that fixed the state system. Some how I deleted and forgot that I had already removed the other on level 2. *I did update unity from an earlier version to an lts release and alot of things have went missing or have moved. As for the //asset being added I suspect this issue might have came from doing backups of my game and having to restore one time. OR I did have an issue that my package manager lost its ability to show updates of my assets currently installed that I think I tracked down to a partition error on my flash drive. Once I removed the FAT partition and moved to NTFS that ability has came back to my game. I wonder if the two issues are related? Ill do some more looking. Thanks again.
 
Top