Exemplo n.º 1
0
        private static void CreateDollyCameraWithPath()
        {
            CinemachineVirtualCamera vcam = InternalCreateVirtualCamera(
                "CM vcam", true, typeof(CinemachineComposer), typeof(CinemachineTrackedDolly));
            GameObject go = new GameObject(
                GenerateUniqueObjectName(typeof(CinemachineSmoothPath), "DollyTrack"));

            Undo.RegisterCreatedObjectUndo(go, "create track");
            CinemachineSmoothPath path = Undo.AddComponent <CinemachineSmoothPath>(go);
            var dolly = vcam.GetCinemachineComponent <CinemachineTrackedDolly>();

            Undo.RecordObject(dolly, "create track");
            dolly.m_Path = path;
        }
Exemplo n.º 2
0
    /*
     * Stops the movement if the dolly has reached its end. Perhaps unneccessary since the game should end when player hits the top frame of the camera.
     */
    private void CheckMovement()
    {
        CinemachineSmoothPath currentPath = (CinemachineSmoothPath)dolly.m_Path;
        float diff = Mathf.Abs(dolly.m_PathPosition - (currentPath.m_Waypoints.Length - 1));

        if (diff <= DOLLY_AT_END_DIFF)
        {
            isMoving = false;
        }
        else
        {
            isMoving = true;
        }
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        if (saveCamera == null)
        {
            saveCamera = GetComponent <Camera>();
        }

        Speed                  = 14.0f;
        refScriptCart          = gameObject.transform.GetChild(1).gameObject.GetComponent <CinemachineDollyCart>();
        refScriptTrack         = gameObject.transform.root.GetChild(1).gameObject.GetComponent <CinemachineSmoothPath>();
        refScriptVideoRecorder = gameObject.GetComponent <CaptureFromCamera>();
        refScriptVideoRecorder._outputFolderPath = Application.persistentDataPath + "/Save_Media/";
        refScriptCart.m_Position = 0;
        refScriptCart.m_Speed    = 0.0f;
    }
    protected override void Start()
    {
        base.Start();

        bossPath = BattleManager.Instance.GetBossPath();
        if (bossPath != null)
        {
            bossCart = BattleManager.Instance.GetBossCart();
            if (bossCart != null)
            {
                bossCartTran  = bossCart.transform;
                bossCartSpeed = bossCart.m_Speed;
            }
        }
        StartCoroutine(Summon());
    }
Exemplo n.º 5
0
    /*
     * Adds a waypoint to the DollyTrack with SEGMENT_LENGTH below the last one (y-axis).
     * Ex. Waypoints = [(0,0,0)] => Waypoints = [(0,0,0),(0, -SEGMENT_LENGTH, 0)]
     */
    public void AddSegmentPointToPath()
    {
        currentSegmentIndex++;

        CinemachineSmoothPath currentPath = (CinemachineSmoothPath)dolly.m_Path;
        int currentPathLength             = currentPath.m_Waypoints.Length;

        CinemachineSmoothPath.Waypoint[] newWayPoints = new CinemachineSmoothPath.Waypoint[currentPath.m_Waypoints.Length + 1];
        for (int i = 0; i < currentPath.m_Waypoints.Length; i++)
        {
            newWayPoints[i] = currentPath.m_Waypoints[i];
        }
        newWayPoints[currentPath.m_Waypoints.Length]          = new CinemachineSmoothPath.Waypoint();
        newWayPoints[currentPath.m_Waypoints.Length].position = new Vector3(dollyXPos, (-1) * currentSegmentIndex * SEGMENT_LENGTH);
        currentPath.m_Waypoints = newWayPoints;
    }
Exemplo n.º 6
0
        private static void CreateDollyTrackWithCart()
        {
            GameObject go = new GameObject(
                GenerateUniqueObjectName(typeof(CinemachineSmoothPath), "DollyTrack"));

            Undo.RegisterCreatedObjectUndo(go, "create track");
            CinemachineSmoothPath path = Undo.AddComponent <CinemachineSmoothPath>(go);

            Selection.activeGameObject = go;

            go = new GameObject(GenerateUniqueObjectName(typeof(CinemachineDollyCart), "DollyCart"));
            Undo.RegisterCreatedObjectUndo(go, "create cart");
            CinemachineDollyCart cart = Undo.AddComponent <CinemachineDollyCart>(go);

            Undo.RecordObject(cart, "create track");
            cart.m_Path = path;
        }
Exemplo n.º 7
0
        /// <summary>惑星fromからtoへのパスを設定. カメラ設定用にPlayerも必要</summary>
        public void Initialize(Transform from, Transform to, Transform player)
        {
            // コンポーネントを取得.
            Rail   = this.GetComponent <Rail>();
            m_path = Rail.GetComponent <CinemachineSmoothPath>();

            // パスの設定.
            SetWayPoints(from, to, out Vector3 start);
            transform.SetPositionAndRotation(start, Quaternion.identity);
            m_path.InvalidateDistanceCache();
            Rail.PathDuration = Mathf.Max(m_path.PathLength / m_moveSpeed, m_minimumDuration);

            // 目標の設定.
            Rail.GoalPlanet = to;

            // カメラの設定.
            SetCameraParameters(player);
        }
Exemplo n.º 8
0
        private static void CreateDollyCameraWithPath()
        {
            CinemachineVirtualCamera vcam = InternalCreateVirtualCamera(
                "CM vcam", true, typeof(CinemachineComposer), typeof(CinemachineTrackedDolly));
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineSmoothPath), "DollyTrack"),
                typeof(CinemachineSmoothPath));

            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create track");
            CinemachineSmoothPath path = go.GetComponent <CinemachineSmoothPath>();
            var dolly = vcam.GetCinemachineComponent <CinemachineTrackedDolly>();

            Undo.RecordObject(dolly, "create track");
            dolly.m_Path = path;
        }
        static void CreateDollyCameraWithPath(MenuCommand command)
        {
            CinemachineEditorAnalytics.SendCreateEvent("Dolly Camera with Track");
            GameObject go = InspectorUtility.CreateGameObject(
                GenerateUniqueObjectName(typeof(CinemachineSmoothPath), "DollyTrack"),
                typeof(CinemachineSmoothPath));

            SetParentToMenuContextObject(go, command);
            if (SceneView.lastActiveSceneView != null)
            {
                go.transform.position = SceneView.lastActiveSceneView.pivot;
            }
            Undo.RegisterCreatedObjectUndo(go, "create track");
            CinemachineSmoothPath path = go.GetComponent <CinemachineSmoothPath>();

            CinemachineVirtualCamera vcam = InternalCreateVirtualCamera(
                "CM vcam", true, typeof(CinemachineComposer), typeof(CinemachineTrackedDolly));

            SetParentToMenuContextObject(vcam.gameObject, command);
            vcam.GetCinemachineComponent <CinemachineTrackedDolly>().m_Path = path;
        }
Exemplo n.º 10
0
    /// <summary>
    /// 카트 움직이기
    /// 1. 패스 지정해주기
    /// 2. 카메라 위치 등변경하기
    /// 3. 카트 active해서 움직이게 하기
    /// </summary>
    /// <param name="_dollyTrack">움직일 트랙</param>
    /// <param name="_curPanel">현재 패널</param>
    /// <param name="_nextPanel">다음(도착) 패널</param>
    /// /// <param name="_speed">속도</param>
    public void DollyCameraMove(GameObject _dollyTrack, GameObject _curPanel, GameObject _nextPanel, int _speed)
    {
        UIManager.instance.CartStartClosePanel(_curPanel, _nextPanel);

        smoothPath = _dollyTrack.GetComponent <CinemachineSmoothPath>();

        // 1.
        dollyCart.GetComponent <CinemachineDollyCart>().m_Path   = smoothPath;
        dollyCart.GetComponent <CinemachineDollyCart>().m_Speed *= _speed;
        if (_speed > 0)
        {
            dollyCart.GetComponent <CinemachineDollyCart>().m_Position = 0f;
        }
        dollyCart.GetComponent <DollyCamera>().smoothPath = smoothPath;

        // 2.
        cam.gameObject.transform.SetParent(dollyCart.transform);
        cam.transform.position = dollyCart.transform.position;
        cam.transform.rotation = dollyCart.transform.rotation;

        // 3.
        dollyCart.SetActive(true);
    }
 static void DrawGizmos(CinemachineSmoothPath path, GizmoType selectionType)
 {
     CinemachinePathEditor.DrawPathGizmo(path,
                                         (Selection.activeGameObject == path.gameObject)
         ? path.m_Appearance.pathColor : path.m_Appearance.inactivePathColor);
 }
    private void CreateEnemyPath(Transform enemytransform, Transform bulletTransform, CinemachinePathController selectedPath)
    {
        Quaternion rotation = Quaternion.Euler(Vector3.up * bulletTransform.root.eulerAngles.y);

        trackInstance = Instantiate(selectedPath.path, enemytransform.position, rotation);
    }
 private void CreateBulletPath(Transform bulletTransform, CinemachinePathController selectedPath)
 {
     trackInstance = Instantiate(selectedPath.path, bulletTransform);
     trackInstance.transform.localPosition = selectedPath.transform.position;
     trackInstance.transform.localRotation = selectedPath.transform.rotation;
 }
Exemplo n.º 14
0
 private void Awake()
 {
     m_Path = GetComponent <CinemachineSmoothPath>();
     m_DollyCart.m_Speed = 0;
 }
Exemplo n.º 15
0
        /// <summary>
        /// pathに沿って円状にアイテムを配置する
        /// </summary>
        /// <param name="itemPrefab">作成するアイテム</param>
        /// <param name="path">対象のpath</param>
        /// <param name="circleCount">作成する円の数</param>
        /// <param name="unitItemCount">円一つ当たりの個数</param>
        /// <param name="startpos">作成を開始する場所(0~1)</param>
        /// <param name="endpos">作成を終了するする場所(0~1)</param>
        /// <param name="radias">円の大きさ</param>
        /// <returns></returns>
        public static List <GameObject> GenerateItem_aroundPath(GameObject itemPrefab, CinemachineSmoothPath path, int circleCount, int unitItemCount, float startpos = 0, float endpos = 1, float radias = 2.0f)
        {
            //値の修正
            endpos   = Mathf.Clamp01(endpos);
            startpos = Mathf.Clamp01(startpos);
            if (endpos <= startpos)
            {
                var temp = endpos;
                endpos   = startpos;
                startpos = temp;
            }
            //経路の作成
            var posList  = new List <(Vector3 pos, Vector3 direction)>();
            var distance = (endpos - startpos) / circleCount;

            //ちょっとずれた位置を調べてpathの傾きを取得
            for (int i = 0; i < circleCount; i++)
            {
                var checkPos = startpos + distance * i;
                var dl       = (checkPos < 1.0f) ? 0.01f : -0.01f;
                var pos      = path.EvaluatePositionAtUnit(checkPos, CinemachinePathBase.PositionUnits.Normalized);
                var dpos     = path.EvaluatePositionAtUnit(checkPos + dl, CinemachinePathBase.PositionUnits.Normalized);
                posList.Add((pos, ((dpos - pos) * Mathf.Sign(dl)).normalized));
            }

            //アイテムの生成
            List <GameObject> resultList = new List <GameObject>();

            foreach (var posData in posList)
            {
                var center = posData.pos;
                var up     = posData.direction;
                resultList.AddRange(GenerateItem_circle(itemPrefab, center, radias, unitItemCount, up));
            }
            return(resultList);
        }