Question by 
               DavidBoba · Aug 19, 2021 at 03:15 AM · 
                prefabrandomrandom.range  
              
 
              How to get random numbers for prefab objects in scene?
Hello, I have 2 prefab objects in my scene that I am trying to move randomly in my map, when I hit play the objects always move towards the same position even though I have added random.Range. I have tried googling and watching videos and can't figure out what is wrong. Any advice would be appreciated thank you!
public class EnemyMove : MonoBehaviour { Transform playerFollow;
 //Animation
 public Animator movement;
 public float speed;
 private float waitTime;
 public float startWaitTime;
 public float smoothSpeed = 10f;
 public Transform moveSpot;
 //Set Boundaries for patrol area
 public float minX;
 public float maxX;
 public float minZ;
 public float maxZ;
 //Raycast Detection of players
 Ray detectPlayerRay;
 public Color rayColor;
 //public float rayHitDistance;
 public bool follow;
 public float rayDistance = 10f;
 public float setRayCenter = 1f;
 private void Start()
 {
     
     playerFollow = GameObject.FindGameObjectWithTag("Player").transform;
     waitTime = startWaitTime;
     moveSpot.position = new Vector3(UnityEngine.Random.Range(minX, maxX), 0, UnityEngine.Random.Range(minZ, maxZ));
 }
 
               }
,
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
How to spawn a prefab every 5 second randomly between a set range? 0 Answers
Use all variables from array (in Random.Range()) 2 Answers
how to randomly choose a value from array 3 Answers
Trying to implement xorshift with deplorable results (PRNG) 0 Answers
Random.Range doesn´t seem to be working (or a switch statement) 1 Answer