Esempio n. 1
0
    protected virtual void Awake()
    {
        Instance = this;

        // Instantiate controller prefab
        if (Controller == null)
        {
            GameObject go = Instantiate(BodyPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            Controller = go.GetComponent <VZController>();
            Controller.transform.localScale = Vector3.one;
            Controller.name = "VZController";
            DontDestroyOnLoad(Controller);
        }

        // Reparent it to us
        Controller.transform.SetParent(transform, false);

        // Raycast mask
        mRaycastMask = ~(LayerMask.GetMask("VZPlayerCollider") | LayerMask.GetMask("Ignore Raycast") | LayerMask.GetMask("VZObjectCollider"));

#if VZ_PLAYMAKER
        // Cache PlayMaker FSM variable references.
        mPlayMakerVariables.Init();
#endif
    }
Esempio n. 2
0
    public void AttachPlayer(VZPlayer player)
    {
        // Unparent old camera
        if (mCamera != null)
        {
            mCamera.SetParent(null, false);
        }

        // Set new camera and parent ourselves to player
        if (player != null)
        {
            mCamera = player.Camera;
            transform.SetParent(player.transform, false);
        }
        else
        {
            mCamera = null;
            transform.SetParent(null, false);
        }

        // Parent new camera
        if (mCamera != null)
        {
            mCamera.SetParent(mCameraOffset, false);
        }
    }