- Home /
move object with perlin noise and equal spread
I'm trying to make a program that moves an object through any point between 0 and 1. I tried using a noise map for each axis on an object to achieve the effect, but as I added more game objects it appears that they are more likely to be in the center of the range. I used this code for the effect
public float speed;
float locationX;
float locationY;
float locationZ;
private void Start()
{
//randomize location in noise
locationX = Random.Range(0f, 100f);
locationY = Random.Range(0f, 100f);
locationZ = Random.Range(0f, 100f);
}
void Update()
{
moveInCaptivity(speed);
}
//moves in captivity
void moveInCaptivity(float moveSpeed)
{
//sets x, y, z coordinates
float newLocationX = Mathf.PerlinNoise(goThroughNoise, locationX);
float newLocationY = Mathf.PerlinNoise(goThroughNoise, locationY);
float newLocationZ = Mathf.PerlinNoise(goThroughNoise, locationZ);
//goes through noise
goThroughNoise += .1f * moveSpeed * Time.deltaTime;
transform.localPosition = new Vector3(newLocationX, newLocationY, newLocationZ);
}
Instead of this effect, I'm wondering if there's a way to do the same effect but for the object to move throughout the range equally so each object is spread out equally instead of having a higher chance to be clumped closer in the center.
Your answer
Follow this Question
Related Questions
Making enemies jump at random (c#) 2 Answers
Simple 2D Enemy AI 3 Answers
random direction of enemy when collide whit wall 1 Answer
How to stop MoveTowards teleporting 1 Answer
Make an object move towards random spot on another objects edge? 1 Answer