Пример #1
0
    public Mesh UpdateMesh(WaterWavesController wavesController, float xOffset, float zOffset)
    {
        for (int i = 0; i < _vertexCount; i++)
        {
            Vector3 vert = _vertices[i];
            vert.y       = wavesController.GetHeightAtPosition(vert.x + xOffset, vert.z + zOffset);
            _vertices[i] = vert;
        }

        _mesh.SetVertices(_vertices);
        _mesh.RecalculateNormals();
        return(_mesh);
    }
Пример #2
0
    public bool IsUnderWater(Vector3 position)
    {
        if (_wavesController.GetHeightAtPosition(position.x, position.z) >= position.y + _yOffset)
        {
            return(true);
        }

        return(false);
    }
Пример #3
0
    private void Update()
    {
        if (Connected)
        {
            int lastIndex = _hose.positionCount - 1;

            _hose.SetPosition(0, _origin.position);
            _hose.SetPosition(lastIndex, _target.position);
            if (lastIndex > 1)
            {
                Vector3 directionToNextVertex = (_target.position - _origin.position) / lastIndex;

                for (int i = 1; i < lastIndex; i++)
                {
                    Vector3 vertexPosition = _origin.position + directionToNextVertex * i;
                    vertexPosition.y = _wavesController.GetHeightAtPosition(vertexPosition.x, vertexPosition.z) + _heightOffest;
                    _hose.SetPosition(i, vertexPosition);
                }
            }
        }
    }