Why Does Camera Anchor Reset?

jmarsh411

New member
I am another one of those people working on a multiplayer game where one top-down camera is supposed to follow multiple players. I saw this feature is in the backlog, but in the meantime I don't wanna hold up my game waiting for this. For what it's worth I'm using UCC version 2.2.8 with the Photon add-on.

The best workaround I have so far is to create an arbitrary game object which follows the center of the player via a script. It will also tell the camera to adjust its view distance based on character distance. This works well, but I have a small problem that the anchor is being reset in the private InitializeAnchor method since it's not a child of the character.

Code:
        private void InitializeAnchor()
        {
            // Assign the anchor to the bone transform if auto anchor is enabled. Otherwise use the character's Transform.
            Transform anchor = null;
            if (m_AutoAnchor && (anchor = m_Character.GetComponent<Animator>().GetBoneTransform(m_AutoAnchorBone)) != null) {
                m_Anchor = anchor;
            } else if (m_Anchor != null && !m_Anchor.IsChildOf(m_Character.transform)) {
                m_Anchor = null;
            }

            if (m_Anchor == null) {
                m_Anchor = m_CharacterTransform;
            }
        }

I assume all code that's there is for good reason, so I'm wondering why this reset is needed. Nothing seems to go wrong if I just drag the anchor back in at runtime.
 
An anchor is necessary so that code is ensuring an anchor is set. An arbitrary GameObject is the right approach for that situation.
 
Thanks for the reply. The camera for my game isn't meant to follow a specific player or any of that player's bones, so I'll just comment that line out.
 
Top