Attach Camera to Character (Networking)

devomage

Member
I am trying to attach the camera to a character where the UltimateCharacterLocomotion component is disabled. It works again after I manually enable the component. How does the camera follow properly in this case?
 
How are you attaching the camera and what issues are you getting when the UCL component is disabled? You should be able to manually set the camera's Anchor to any transform.
 
Note that the character tells the camera controller to move within the kinematic object manager so when the character is disabled the camera will not move. This ensures the character/camera update order is correct.
 
With a networking add-on the input is disabled:

C#:
//line #46 --- NetworkCharacterLocomotionHandler.cs

if (m_NetworkInfo.IsLocalPlayer()) {
    
} else {
    // Non-local players will not be controlled with player input.
    enabled = false;
    m_CharacterLocomotion.enabled = false;
}

On an authoratative server, i have an "Attach Camera" button for each player. I attach the camera if the camera character is null similar to the DemoManager Init... this all works fine.

I haven't tried to replace the above with "OnEnableGameplayInput". Would that work? Any other ideas on how to attach the camera? Ultimately, I would like to be able to attach it to any player or AI Agent. This would let the server host choose which Character to spectate.
 
I haven't tried to replace the above with "OnEnableGameplayInput". Would that work?
Yes - I would try that route. It's better to use the event rather than disabling the component itself since when you disable the component it also unregisters itself from certain things. If you haven't seen it this script may help with switching between AI and player (though it's not networked):

 
This ended up being the issue: (network LookSource.cs)

C#:
private void Start()
{
    // Remote characters will not have a local look source. The current component should act as the look source.
    if (!isLocalPlayer)
    {
        EventHandler.UnregisterEvent<ILookSource>(m_GameObject, "OnCharacterAttachLookSource", OnAttachLookSource);
        EventHandler.ExecuteEvent<ILookSource>(m_GameObject, "OnCharacterAttachLookSource", this);
    }
}
 
Top