public override double this[double x, double y, double z] { get { double value = 0.0; double curPersistence = 1.0; x *= Frequency; y *= Frequency; z *= Frequency; for (int curOctave = 0; curOctave < OctaveCount; curOctave++) { // Make sure that these floating-point values have the same range as a 32- // bit integer so that we can pass them to the coherent-noise functions. double nx = NoiseGen.MakeInt32Range(x); double ny = NoiseGen.MakeInt32Range(y); double nz = NoiseGen.MakeInt32Range(z); // Get the coherent-noise value from the input value and add it to the // final result. int localSeed = Seed + curOctave; double signal = NoiseGen.GradientCoherentNoise3D(nx, ny, nz, localSeed, NoiseQuality); value += signal * curPersistence; // Prepare the next octave. x *= Lacunarity; y *= Lacunarity; z *= Lacunarity; curPersistence *= Persistence; } return(value); } }
public void Test() { //Teeb world geni randomiks xOffset = Random.Range(0, 9999); yOffset = Random.Range(0, 9999); //Teeb kindlaks et mapi laiused oleksid paaritud arvud if (width % 2 == 0) { width += 1; } if (heigth % 2 == 0) { heigth += 1; } //Genereerib noisemapi float[,] noiseMap = NoiseGen.GenerateNoise(width, heigth, scale, levels, intensity, opacity, xOffset, yOffset, opacity2); //DrawTexture drawScript = GetComponent<DrawTexture>(); //drawScript.DrawNoise(width,heigth,noiseMap); MakeMesh makeMesh = GetComponent <MakeMesh>(); makeMesh.CreateMesh(width, heigth, noiseMap, heigths, coast, waterLevel, mapRadius, animalSpawnDist); }
public override double GetValue(double x, double y, double z) { double value = 0.0; double signal = 0.0; double curPersistence = 1.0; double nx, ny, nz; int seed; x *= m_frequency; y *= m_frequency; z *= m_frequency; for (int curOctave = 0; curOctave < m_octaveCount; curOctave++) { // Make sure that these floating-point values have the same range as a 32- // bit integer so that we can pass them to the coherent-noise functions. nx = NoiseGen.MakeInt32Range(x); ny = NoiseGen.MakeInt32Range(y); nz = NoiseGen.MakeInt32Range(z); // Get the coherent-noise value from the input value and add it to the // final result. seed = (int)((m_seed + curOctave) & 0xffffffff); signal = NoiseGen.GradientCoherentNoise3D(nx, ny, nz, seed, m_noiseQuality); value += signal * curPersistence; // Prepare the next octave. x *= m_lacunarity; y *= m_lacunarity; z *= m_lacunarity; curPersistence *= m_persistence; } return(value); }
void Start() { maxViewDist = detailLevels[detailLevels.Length - 1].lodThreshold; chunkVisibleInViewDist = Mathf.RoundToInt(maxViewDist / chunkSize); mapGenerator = FindObjectOfType <NoiseGen>(); UpdateVisibleChunks(); }
public void GenerateTerrain() { float[,] noiseMap = NoiseGen.GenerateNoiseMap(width, height, seed, scale, octaves, persistance, lacunarity, offset); FoliageGen.removeAllFoliage(); TerrainRendering terrainRendering = FindObjectOfType <TerrainRendering>(); List <ChunkData> chunks = NoiseGen.ChunkNoiseMap(noiseMap); List <MeshData> meshData = new List <MeshData>(); foreach (ChunkData chunkData in chunks) { meshData.Add(MeshGen.GenerateTerrainMesh(chunkData.heightMap, meshHeightMultiplier, meshHeightCurve, chunkData.chunkCoords, regions)); } if (useShader) { terrainRendering.DrawMesh(meshData, meshScale, shaderMaterial); } else { terrainRendering.DrawMesh(meshData, meshScale, null); } UpdateShaderData(); }
/// <summary> /// Handles assignment of map colours and height modifications using the passed array of generated perlin values /// </summary> public void GenerateMap() { //2D array of float values generated within the NoiseGen script and returned here float[,] noiseGrid = NoiseGen.GenerateNoise(mapWidth, mapHeight, noiseScale, octaves, persistance, seed, offset); Color[] colourMap = new Color[mapWidth * mapHeight]; for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { float currentHeight = noiseGrid[x, y]; for (int i = 0; i < regions.Length; i++) { if (currentHeight <= regions[i].height) { colourMap[y * mapWidth + x] = regions[i].colour; break; } } } } MapDisplay mapDisplay = FindObjectOfType <MapDisplay>(); mapDisplay.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseGrid, meshHeightMultiplier, meshHeightCurve), TextureGenerator.TextureFromColourMap(colourMap, mapWidth, mapHeight)); terrainObject.AddComponent <MeshCollider>(); //Calls for the terrain to be populated with environmental objects MapObjectGeneration.GenerateObjects(terrainObject, treeParent, rockParent, metalParent, crystalParent, playerBuildingsParent, mapWidth, mapWidth); navMeshSurface = terrainObject.GetComponent <NavMeshSurface>(); navMeshSurface.BuildNavMesh(); NavMeshHit navHit; Vector3 engineerSpawn; bool engineerSpawned = false; GameObject spawnedUnit; do { //Selects a random vector3 position within a sphere centering around the transform position of the base core engineerSpawn = Random.insideUnitSphere * 50 + GameObject.Find("BaseCore(Clone)").transform.position; //Creates a new ray object using this random position and sets it to be above the terrain Ray raycast = new Ray(new Vector3(engineerSpawn.x, 180.0f, engineerSpawn.z), Vector3.down); //Casts another collider raycast using the ray object if (NavMesh.SamplePosition(engineerSpawn, out navHit, 200f, NavMesh.AllAreas)) { engineerSpawn = navHit.position; //Then spawns the engineer unit spawnedUnit = Instantiate(Resources.Load("PlayerUnits/Engineer"), engineerSpawn, Quaternion.identity, GameObject.Find("UnitParent").transform) as GameObject; spawnedUnit.GetComponent <Unit>().SpawnUnit(); engineerSpawned = true; } }while (!engineerSpawned); }
MapData GenerateMapData(Vector2 center) { float[,] noiseMap = NoiseGen.GenerateNoiseMap(mapChunkSize + 2, mapChunkSize + 2, seed, noiseScale, octaves, persistance, lacunarity, center + offset, normalizeMode);//mapchunksize + 2 cause border Color[] colorMap = new Color[mapChunkSize * mapChunkSize]; for (int y = 0; y < mapChunkSize; y++) { for (int x = 0; x < mapChunkSize; x++) { if (useFalloff) { noiseMap[x, y] = Mathf.Clamp01(noiseMap[x, y] - falloffMap[x, y]); } float currentHeight = noiseMap[x, y]; for (int i = 0; i < regions.Length; i++) { if (currentHeight >= regions[i].height) { colorMap[y * mapChunkSize + x] = regions[i].color; } else { break; } } } } return(new MapData(noiseMap, colorMap)); }
// MAP GENERATION MapData GenerateMapData(Vector2 center) { // Get noise map float[,] noiseMap = NoiseGen.GenerateNoiseMap(mapChunkSize, mapChunkSize, seed, noiseScale, octaves, persistance, lacunarity, center + offset, normalizeMode); //Assign Terrain based on height Color[] colorMap = new Color[mapChunkSize * mapChunkSize]; for (int x = 0; x < mapChunkSize; x++) { for (int y = 0; y < mapChunkSize; y++) { float currentHeight = noiseMap[x, y]; for (int i = 0; i < regions.Length; i++) { if (currentHeight >= regions[i].height) { colorMap[y * mapChunkSize + x] = regions[i].color; } else { break; } } } } return(new MapData(noiseMap, colorMap)); }
public override double this[double x, double y] { get { x *= Frequency; y *= Frequency; double value = 0.0; double weight = 1.0; // These parameters should be user-defined; they may be exposed in a // future version of libnoise. const double offset = 1.0; const double gain = 2.0; for (int curOctave = 0; curOctave < OctaveCount; curOctave++) { // Make sure that these floating-point values have the same range as a 32- // bit integer so that we can pass them to the coherent-noise functions. double nx = NoiseGen.MakeInt32Range(x); double ny = NoiseGen.MakeInt32Range(y); // Get the coherent-noise value. int seed = (Seed + curOctave) & 0x7fffffff; double signal = NoiseGen.GradientCoherentNoise2D(nx, ny, seed, NoiseQuality); // Make the ridges. signal = Math.Abs(signal); signal = offset - signal; // Square the signal to increase the sharpness of the ridges. signal *= signal; // The weighting from the previous octave is applied to the signal. // Larger values have higher weights, producing sharp points along the // ridges. signal *= weight; // Weight successive contributions by the previous signal. weight = signal * gain; if (weight > 1.0) { weight = 1.0; } if (weight < 0.0) { weight = 0.0; } // Add the signal to the output value. value += (signal * spectralWeights[curOctave]); // Go to the next octave. x *= Lacunarity; y *= Lacunarity; } return((value * 1.25) - 1.0); } }
public void IterateAutomataIterations3() { string[] inGrid = { "XXXXX", "X...X", "X...X", "X...X", "XXXXX", }; string[] outGrid = { "XXXXX", "XXXXX", "XXXXX", "XXXXX", "XXXXX", }; bool[][] map = GridTest.InitBoolGrid(inGrid); bool[][] compare = GridTest.InitBoolGrid(outGrid); bool[][] result = NoiseGen.IterateAutomata(map, CellRule.None, CellRule.Gte4, 3); Assert.That(result, Is.EqualTo(compare)); }
float PerlinNoise(int x,int y, int z, float scale) { NoiseGenerator = new NoiseGen(cSize,5); float rValue; rValue=NoiseGenerator.GetNoise (((double)x)/scale, ((double)y)/scale, ((double)z)/scale); return rValue; }
/// <summary> /// Generates an output value given the coordinates of the specified input value. /// </summary> /// <param name="x">The x coordinate of the input value.</param> /// <param name="y">The y coordinate of the input value.</param> /// <param name="z">The z coordinate of the input value.</param> /// <returns>The output value.</returns> public override double GetValue(double x, double y, double z) { var ix = (int)(Math.Floor(NoiseGen.MakeInt32Range(x))); var iy = (int)(Math.Floor(NoiseGen.MakeInt32Range(y))); var iz = (int)(Math.Floor(NoiseGen.MakeInt32Range(z))); return((ix & 1 ^ iy & 1 ^ iz & 1) != 0 ? -1.0 : 1.0); }
/// <summary> /// Generates an output value given the coordinates of the specified input value. /// </summary> /// <param name="x">The x coordinate of the input value.</param> /// <returns>The output value.</returns> public override double this[double x] { get { var ix = (int)(Math.Floor(NoiseGen.MakeInt32Range(x))); return((ix & 1) != 0 ? -1.0 : 1.0); } }
void CreateMesh() { NoiseGen noise = new NoiseGen(octaves, lacunarity, gain, perlinScale); vertices = new Vector3[(xSize + 1) * (zSize + 1)]; for (int i = 0, z = 0; z <= zSize; z++) { for (int x = 0; x <= xSize; x++) { // Altering the y value to make uneven terrain float y = 4.3f * noise.GetFractalNoise(transform.position.x + x, transform.position.z + z); vertices[i] = new Vector3(x, y, z); //vertices[i] = new Vector3(x, SamplePerlin(transform.position.x + x, transform.position.z + i), z); if (y > maxTerrainHeight) { maxTerrainHeight = y; } if (y < minTerrainHeight) { minTerrainHeight = y; } i++; } } triangles = new int[xSize * zSize * 6]; int vert = 0; int tris = 0; // Creates the triangles/quad for the mesh for (int z = 0; z < zSize; z++) { for (int x = 0; x < xSize; x++) { // First triangle triangles[tris + 0] = vert + 0; triangles[tris + 1] = vert + xSize + 1; triangles[tris + 2] = vert + 1; // Second triangle triangles[tris + 3] = vert + 1; triangles[tris + 4] = vert + xSize + 1; triangles[tris + 5] = vert + xSize + 2; // 2 triangles make a quad vert++; tris += 6; } vert++; } SetUvs(); SetVertexColours(); }
void FixedUpdate() { if (!cameraPositions [camIndex].isStatic) { Quaternion look; Vector3 camOffset; camOffset = new Vector3(cameraPositions [camIndex].xOffset, cameraPositions [camIndex].yOffset, cameraPositions [camIndex].zOffset); // Moves the camera to match the car's position. rootNode.position = Vector3.Lerp(rootNode.position, car.position, cameraPositions [camIndex].cameraStickiness * Time.fixedDeltaTime); Vector2 noise = new Vector2(); float speedAmplitude = Mathf.Clamp(carPhysics.velocity.magnitude, 0.0f, cameraShakeMaxSpeed) / cameraShakeMaxSpeed; if (isShaking) { noise = NoiseGen.Shake2D(cameraPositions [camIndex].amplitude * speedAmplitude, cameraPositions [camIndex].frequency, cameraPositions [camIndex].octaves, cameraPositions [camIndex].persistance, cameraPositions [camIndex].lacunarity, cameraPositions [camIndex].burstFrequency, cameraPositions [camIndex].burstContrast, Time.time); } carCam.localPosition = camOffset + new Vector3(noise.x, noise.y, 0.0f); RaycastHit[] hits; // AÑADIDO POR KATZE ROT: la variable del tipo Vector3 llamada theVector, sirve para que la camara no de por culo cuando se encuentra con un // obstaculo por debajo del coche. Consiste en modificar la coordenada y, con el valor que sea. Se debe regular al gusto. hits = Physics.RaycastAll(car.position + theVector, (carCam.position - rootNode.position), (rootNode.position - carCam.position).magnitude); foreach (RaycastHit hit in hits) { Transform go = hit.collider.gameObject.transform.parent; Transform prevGo = go; while (go != null) { prevGo = go; go = go.transform.parent; } go = prevGo; if (go != car) { carCam.position = hit.point; } } // If the car isn't moving, default to looking forwards. Prevents camera from freaking out with a zero velocity getting put into a Quaternion.LookRotation if (carPhysics.velocity.magnitude < cameraPositions [camIndex].rotationThreshold) { look = Quaternion.LookRotation(car.forward); } else { look = Quaternion.LookRotation(carPhysics.velocity.normalized); } // Rotate the camera towards the velocity vector. look = Quaternion.Slerp(rootNode.rotation, look, cameraPositions[camIndex].cameraRotationSpeed * Time.fixedDeltaTime); rootNode.rotation = look; } }
private Vector2 generateNoisePoint(Vector2 v2, float flash) { NoiseGen ns = new NoiseGen(); //ns.flash = noiseSource; ns.flash = flash; ns._radius = noiseRadius; Vector2 delta = Vector2.zero; return(v2 + (ns.getPoint(v2) + delta) * noiseLength); }
/// <summary> /// Generates an output value given the coordinates of the specified input value. /// </summary> /// <param name="x">The x coordinate of the input value.</param> /// <returns>The output value.</returns> public override double this[double x] { get { // This method could be more efficient by caching the seed values. Fix // later. x *= Frequency; int xInt = (x > 0.0 ? (int)x : (int)x - 1); double minDist = 2147483647.0; double xCandidate = 0; // Inside each unit cube, there is a seed point at a random position. Go // through each of the nearby cubes until we find a cube with a seed point // that is closest to the specified position. for (int xCur = xInt - 2; xCur <= xInt + 2; xCur++) { // Calculate the position and distance to the seed point inside of // this unit cube. double xPos = xCur + NoiseGen.ValueNoise2D(xCur, Seed); double xDist = xPos - x; double dist = xDist * xDist; if (dist < minDist) { // This seed point is closer to any others found so far, so record // this seed point. minDist = dist; xCandidate = xPos; } } double value; if (EnableDistance) { // Determine the distance to the nearest seed point. double xDist = xCandidate - x; value = xDist * MathConsts.Sqrt3 - 1.0; } else { value = 0.0; } // Return the calculated distance with the displacement value applied. return(value + (Displacement * NoiseGen.ValueNoise1D( (int)(Math.Floor(xCandidate))))); } }
public void IterateAutomataSingle7(CellRule rule, bool expected) { // test to verify all neighbors are influencing decision correctly string[] inGrid = { "X..", "...", "...", }; bool[][] map = GridTest.InitBoolGrid(inGrid); bool[][] result = NoiseGen.IterateAutomata(map, CellRule.None, rule, 1); Assert.That(result[1][1], Is.EqualTo(expected)); }
void Update() { if (cameraPositions [camIndex].isStatic) { // Moves the camera to match the car's position. rootNode.position = car.position; rootNode.rotation = car.rotation; Vector2 noise = new Vector2(); float speedAmplitude = Mathf.Clamp(carPhysics.velocity.magnitude, 0.0f, cameraShakeMaxSpeed) / cameraShakeMaxSpeed; if (isShaking) { noise = NoiseGen.Shake2D(cameraPositions [camIndex].amplitude * speedAmplitude, cameraPositions [camIndex].frequency, cameraPositions [camIndex].octaves, cameraPositions [camIndex].persistance, cameraPositions [camIndex].lacunarity, cameraPositions [camIndex].burstFrequency, cameraPositions [camIndex].burstContrast, Time.time); } carCam.localPosition = new Vector3(cameraPositions [camIndex].xOffset, cameraPositions [camIndex].yOffset, cameraPositions [camIndex].zOffset) + new Vector3(noise.x, noise.y, 0.0f); carCam.rotation = rootNode.rotation; } //Check if Camere has to be changed if (Input.GetButtonDown(cameraAxisName)) { camIndex = (int)Mathf.Repeat(camIndex + 1, cameraPositions.Count); } if (cameraPositions [camIndex].canShake) { RaycastHit groundHit; if (Physics.Raycast(car.position, -car.up, out groundHit)) { if (groundHit.transform.tag == cameraShakeTag) { isShaking = true; } else { isShaking = false; } } } else { isShaking = false; } }
// Start is called before the first frame update public override void OnInspectorGUI() { NoiseGen noiseGen = (NoiseGen)target; if (GUILayout.Button("Blend") || (DrawDefaultInspector() && noiseGen.autoUpdate)) { noiseGen.Blend(); } if (GUILayout.Button("GenerateWorely")) { noiseGen.GenWorelyNoise(); } if (GUILayout.Button("GeneratePerlin")) { noiseGen.GenPerlinNoise(); } }
MapData GenerateMapData(Vector3 center) //correlates noiseMap with a color { if (mode is Mode.compute || mode is Mode.radius) { float[] noiseMap = NoiseGen.GenerateNoise( size, seed, scale, octaves, persistence, lacunarity, center + offset, noiseGen); return(new MapData(noiseMap, color)); } else { float[,,] noiseMap = NoiseGen.GenerateNoise( size, seed, scale, octaves, persistence, lacunarity, center + offset); return(new MapData(noiseMap, color)); } }
public Generator(uint seed, NoiseType noiseType) { Seed = seed; switch (noiseType) { case NoiseType.SIMPLEX: noiseGen = new SimplexNoise(seed, 0.05, 0.5, false); break; case NoiseType.PERLIN: //noiseGen = new PerlinNoise(seed); break; case NoiseType.CUSTOM: //noiseGen = new CustomNoise(seed); break; } Generate(); }
public static async Task <double[, ]> GenerateHeatmap(NoiseGen noise, int yin, int xin, double[,] heightMap = null) { Task[] tasks = new Task[yin]; double[,] heatmap = new double[yin, xin]; for (int y = 0; y < yin; y++) { double gradient = GenerateGradient((double)y / yin); int yCopy = y; tasks[y] = Task.Factory.StartNew(() => { for (int x = 0; x < xin; x++) { heatmap[yCopy, x] = Lerp(noise.FractalFBM(4, 2, x, yCopy), gradient, .85) * (heightMap != null ? 1 - ((heightMap[yCopy, x] + 1) / 2) : 1); } }); } await Task.WhenAll(tasks); return(heatmap); }
MapData GenerateMapData(Vector2 center) { float[,] noiseMap = NoiseGen.GenerateNoiseMap(mapChunkSize, mapChunkSize, seed, noiseScale, octaves, persistance, lacunarity, center + offset); Color[] colorMap = new Color[mapChunkSize * mapChunkSize]; for (int y = 0; y < mapChunkSize; y++) { for (int x = 0; x < mapChunkSize; x++) { float currentHeight = noiseMap[x, y]; for (int i = 0; i < regions.Length; i++) { if (currentHeight <= regions[i].height) { colorMap[y * mapChunkSize + x] = regions[i].color; break; } } } } return(new MapData(noiseMap, colorMap)); }
public override double GetValue(double x, double y, double z) { // This method could be more efficient by caching the seed values. Fix // later. x *= m_frequency; y *= m_frequency; z *= m_frequency; int xInt = (x > 0.0 ? (int)x : (int)x - 1); int yInt = (y > 0.0 ? (int)y : (int)y - 1); int zInt = (z > 0.0 ? (int)z : (int)z - 1); double minDist = 2147483647.0; double xCandidate = 0; double yCandidate = 0; double zCandidate = 0; // Inside each unit cube, there is a seed point at a random position. Go // through each of the nearby cubes until we find a cube with a seed point // that is closest to the specified position. for (int zCur = zInt - 2; zCur <= zInt + 2; zCur++) { for (int yCur = yInt - 2; yCur <= yInt + 2; yCur++) { for (int xCur = xInt - 2; xCur <= xInt + 2; xCur++) { // Calculate the position and distance to the seed point inside of // this unit cube. double xPos = xCur + NoiseGen.ValueNoise3D(xCur, yCur, zCur, m_seed); double yPos = yCur + NoiseGen.ValueNoise3D(xCur, yCur, zCur, m_seed + 1); double zPos = zCur + NoiseGen.ValueNoise3D(xCur, yCur, zCur, m_seed + 2); double xDist = xPos - x; double yDist = yPos - y; double zDist = zPos - z; double dist = xDist * xDist + yDist * yDist + zDist * zDist; if (dist < minDist) { // This seed point is closer to any others found so far, so record // this seed point. minDist = dist; xCandidate = xPos; yCandidate = yPos; zCandidate = zPos; } } } } double value; if (m_enableDistance) { // Determine the distance to the nearest seed point. double xDist = xCandidate - x; double yDist = yCandidate - y; double zDist = zCandidate - z; value = (Math.Sqrt(xDist * xDist + yDist * yDist + zDist * zDist) ) * MathConst.SQRT_3 - 1.0; } else { value = 0.0; } // Return the calculated distance with the displacement value applied. return(value + (m_displacement * (double)NoiseGen.ValueNoise3D( (int)(Math.Floor(xCandidate)), (int)(Math.Floor(yCandidate)), (int)(Math.Floor(zCandidate))))); }
public void GenerateFoliage() { float[,] treeNoiseMap = NoiseGen.GenerateTreeNoiseMap(width, height); FoliageGen.GenerateFoliage(treeNoiseMap, regions, forestAmount, meshScale, meshHeightCurve, meshHeightMultiplier); }
void FixedUpdate() { if (playerCoop.activeInHierarchy) { power = player.GetComponent <PlayerController> ().power || playerCoop.GetComponent <PlayerController> ().power; } else { power = player.GetComponent <PlayerController> ().power; } Vector3 playerPos = GetCenterOfPlayers() + offset; Vector2 fakeMousePosition; Vector3 mousePos; if (player.GetComponent <PlayerController>().useGamePad) { fakeMousePosition = player.GetComponent <PlayerController>().GetAxis(); //mousePos = new Vector3(player.GetComponent<Rigidbody2D> ().velocity.x * 1 + playerPos.x, player.GetComponent<Rigidbody2D> ().velocity.y * 1 + playerPos.y, offset.z); mousePos = playerPos; } else { fakeMousePosition = (Vector2)Input.mousePosition; mousePos = new Vector3(Camera.main.ScreenToWorldPoint(fakeMousePosition).x, Camera.main.ScreenToWorldPoint(fakeMousePosition).y, offset.z); } //mousePos = new Vector3 (Camera.main.ScreenToWorldPoint (fakeMousePosition).x, Camera.main.ScreenToWorldPoint (fakeMousePosition).y, offset.z); float distMouse2Player = Vector3.Distance(playerPos, mousePos); float distCamera2Player = Vector3.Distance(playerPos, transform.position); Vector3 mouseVector = (mousePos - GetCenterOfPlayers()).normalized; if (distMouse2Player >= maxDistance()) { distMouse2Player = maxDistance(); } Vector3 targetCameraPos = new Vector3(mouseVector.x * distMouse2Player + playerPos.x, mouseVector.y * distMouse2Player + playerPos.y, offset.z); float speed = (distMouse2Player + distCamera2Player) / 2; //transform.position = targetCameraPos; transform.position = Vector3.Lerp(transform.position, targetCameraPos, Time.fixedDeltaTime * speed); if (playerCoop.activeInHierarchy) { distanceBetweenPlayersX = Mathf.Abs(player.transform.localPosition.x - playerCoop.transform.localPosition.x); distanceBetweenPlayersY = Mathf.Abs(player.transform.localPosition.y - playerCoop.transform.localPosition.y); Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, Mathf.Max(distanceBetweenPlayersX - 10, distanceBetweenPlayersY), Time.fixedDeltaTime * speed) * zoom.Evaluate(shake * 10f); } if (Camera.main.orthographicSize < 5) { Camera.main.orthographicSize = 5 * zoom.Evaluate(shake * 10f); } if (shake > 0) { transform.position = NoiseGen.Shake(amplitude, frequency, octaves, persistance, lacunarity, burstFrequency, burstContrast, Time.time, transform.position); shake -= Time.fixedDeltaTime; } else { shake = 0; } }
public ScaledNoise(NoiseGen Noise) { this.Noise = Noise; Bias = 0; Scale = 1; }