- Home /
Question by
MagicalBilly · Aug 06, 2015 at 09:30 PM ·
c#for-loopnoise
Why is this always returning zero?
I have the following snippet of code:
using UnityEngine;
public class TestScript : MonoBehaviour
{
public float heightScale;
public float xScale;
void Start()
{
for(int x = 0; x <= 25; ++x)
{
float height = heightScale * Mathf.Floor(Mathf.PerlinNoise(xScale * x, 0));
print(height);
}
}
}
Whenever I input any values for heightScale
, and xScale
, I always get an output of 0
twenty-five times in the console. Can anyone provide an explanation as to why this is happening?
Comment
Best Answer
Answer by tanoshimi · Aug 06, 2015 at 09:30 PM
Because Mathf.PerlinNoise() returns a value between 0.0 - 1.0, so Mathf.Floor() of that will always be 0.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Smoothing random noises with different amplitudes 0 Answers
[C#] Wondering what is amiss with my 1D Perlin Noise Terrain Generator? 2 Answers
C# Killfeed issues 0 Answers