How to switch UFPS Controller off and on between different cameras?

Sarr

New member
Hello,

Thank you for this great asset, learning it but there are challenges. I need to switch back and forth between modes - UFPS Character Controller has to be turned off so I can release its camera, then get into another camera with completely different gameplay (flying vehicle).
Currently I just turned off game objects "Game", "Nolan" and "Main Camera" then successfully got into another camera by just enabling it. Disabling this new camera and its vehicle controller works fine too, but then re-enabling those essential UFPS game objects causes "lookat" null references / errors of the UFPS. Seems like UFPS doesn't like to be disabled.
How can I switch into another camera and custom controller while being able to get back into UFPS mode anytime?
It's not a car from the integration I'm afraid, and doesn't use animations yet (will use animation later, but it's gonna be just sitting in the cockpit and custom controller takes over the steering). I also need to keep whole UFPS character (eg. Nolan) stats and inventory persistent to be able to check fps mode inventory / health while in another camera / mode / controller.
 
Instead of disabling components/gameobjects, you could use the OnEnableGameplayInput event to completely disable all character and camera input. You'd then also need to hide the character, which you could do in a couple of ways e.g. disabling the SkinnedMeshRenderer components or setting them to an invisible material.
 
Instead of disabling components/gameobjects, you could use the OnEnableGameplayInput event to completely disable all character and camera input. You'd then also need to hide the character, which you could do in a couple of ways e.g. disabling the SkinnedMeshRenderer components or setting them to an invisible material.
Thanks, got it working. But still my custom controls for the camera doesn't move it. I have to manually disable the CameraController component on the main camera, but I fear it's not the right approach. Is there some other, more proper way to release camera movement without disabling that script?
I have the impression that just disabling it introduces some jitter / lowers performance a bit and or / other things could break.
// update: not sure about performance, looks like maybe it's entirely ok to do it that way.

Oh, after disabling the GameplayInput I used StartEquipUnequip. But how can I get the ID of currently equipped weapon?
 
Last edited:
Ah you want to also manually control the camera during that time? In that case you should use a custom view type and switch to it when entering this mode. The simplest would be to use a view type that just returns the camera's transform position/rotation on Move/Rotate - the "example" at the bottom of this page would work. Then to move/rotate the camera, you'd need to call Move or Rotate on the CameraController (instead of directly moving its transform).

You can use Inventory.GetActiveItem(0) to get the currently active Item in slot 0. You can then use ItemSetManager.GetItemSetIndex to get the item set index of that Item. That's the ID you'd need to pass in to StartEquipUnequip.
 
Top