Esempio n. 1
0
    private void UpdateBones()
    {
        //get position at the center of the spline
        Vector3 tangAtSplineCenter;

        _parts[0].position = math.CalcPositionAndTangentByDistanceRatio(0f, out tangAtSplineCenter);
        //Debug.Log(tangAtSplineCenter);
        _parts[0].rotation = Quaternion.LookRotation(tangAtSplineCenter) * Quaternion.Euler(-90, -90, 0);
        for (int i = 1; i < _parts.Count; i++)
        {
            // print(_parts[i]);
            var posAtSplineCenter = math.CalcPositionAndTangentByDistanceRatio(i * step, out tangAtSplineCenter);
            //Debug.Log(tangAtSplineCenter);
            _parts[i].position = posAtSplineCenter;
            _parts[i].rotation = Quaternion.LookRotation(tangAtSplineCenter) * Quaternion.Euler(-90, -90, 0);
        }
    }
Esempio n. 2
0
    private void Update()
    {
        if (config != null)
        {
            duration = (config.duration.minutes * 60) + config.duration.seconds;
        }

        if (time < 2 && !set)
        {
            time += Time.deltaTime;
            return;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("Escape! Returning to Menu");
            SceneManager.LoadSceneAsync("Scenes/MenuScene");
        }

        if (time >= 2 && !set)
        {
            trackerStartPos = trackerObject.transform.localPosition;
            set             = true;
        }

        offset.x += Input.GetAxis("Mouse X") / 5;

        trackerPosDiff = trackerStartPos - trackerObject.transform.localPosition;
        offset        += new Vector2((-trackerPosDiff.x) / 100, 0);
        if (offset.x > .5f)
        {
            offset.x = .5f;
        }
        else if (offset.x < -.5f)
        {
            offset.x = -.5f;
        }

        distance += Time.deltaTime / duration;

        transform.position = curve.CalcPositionAndTangentByDistanceRatio(distance, out var tangent);
        transform.rotation = Quaternion.LookRotation(tangent);

        playerObject.transform.localPosition = new Vector3(offset.x, offset.y + 0.5f);

        if (started == false)
        {
            var delay = (1f / config.beatsPerMinute) * 5f;
            AudioSource.PlayDelayed(delay);
            started = true;
        }

        if (distance >= 1f)
        {
            PersistantData.Stats.Score = Score;
            SceneManager.LoadSceneAsync("Scenes/EndScene");
        }
    }
Esempio n. 3
0
        /// <summary>
        /// Retransforme tout le mesh
        ///
        /// Attention : ne marche pas si on scale le modèle
        /// </summary>
        public void RebuildMesh()
        {
            if (!_initialStateSet)
            {
                Debug.LogError("L'état initial du mesh n'a pas été défini");
                return;
            }

            if (_renderedMesh != MeshSelection.Cloned)
            {
                return;
            }

            // TODO : les rails courbes en utilisant les Sections des BGCurve
            // curveMath.SectionParts nombre de parties

            // World Space
            // Les tangentes sont normées
            Vector3 newBeginPoint = curveMath.CalcPositionAndTangentByDistanceRatio(0.0f, out Vector3 newBeginTangent);
            Vector3 newEndPoint   = curveMath.CalcPositionAndTangentByDistanceRatio(1.0f, out Vector3 newEndTangent);


            // Début du rail
            Quaternion beginRotation = Quaternion.FromToRotation(_beginInitialTangent, newBeginTangent);

            foreach (int b in beginVertices)
            {
                Vector3 rotatedVector = beginRotation * _beginVerticesOffset[b];
                Vector3 newLocalPoint = meshFilter.transform.InverseTransformPoint(newBeginPoint + rotatedVector);
                vertices[b] = newLocalPoint;
            }


            // Fin du rail
            Quaternion endRotation = Quaternion.FromToRotation(_endInitialTangent, newEndTangent);

            foreach (int e in endVertices)
            {
                Vector3 rotatedVector = endRotation * _endVerticesOffset[e];
                Vector3 newLocalPoint = meshFilter.transform.InverseTransformPoint(newEndPoint + rotatedVector);
                vertices[e] = newLocalPoint;
            }

            ApplyEditing();
        }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        if (activeWorldPath != null)
        {
            BGCcMath math = activeWorldPath.GetComponent <BGCcMath>();

            Vector3 tangent;
            worldBase.transform.position  = math.CalcPositionAndTangentByDistanceRatio(TimeManager.TurnRatio, out tangent);
            worldModel.transform.rotation = Quaternion.LookRotation(tangent, worldBase.transform.position);
        }
    }