This question was 
             closed Apr 16, 2019 at 03:20 PM by 
             CharlieLama for the following reason: 
             
 
            The question is answered, right answer was accepted
 
               Question by 
               CharlieLama · May 13, 2016 at 08:56 AM · 
                spawning  
              
 
              my objects is spawning on the wall
Im trying to spawn candles on the ground, but they will only spawn on the wall. this is my code :
 Ray ray;
 public GameObject candle;
 private Vector3 spawnPoint;
 public int torches = 15;
 public float spawnDistance = 3.0f;
 void Start()
 {
 }
 void Update()
 {
     int x = Screen.width / 2;
     int y = Screen.height / 2;
     ray = Camera.main.ScreenPointToRay(new Vector3(x, y));
     {
         if (Input.GetKeyDown(KeyCode.E))
         {
             RaycastHit hit;
             if (Physics.Raycast(this.transform.position, transform.forward, out hit, spawnDistance))
             {
                 Debug.DrawLine(ray.origin, hit.point, Color.blue, 1);
                 if (hit.collider.tag != "Torch" && torches > 0)
                 {
                     Debug.Log("hit collider");
                     Instantiate(candle, hit.point, Quaternion.identity);
                     torches -= 1;
                 }
             }
         }
     }
 }
 
               i already tried to change the spawnDistance, i do not want them to spawn on my walls, i want them to only spawn on the ground, anyone who can help me?
Thanks in advance!
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by CharlieLama · Apr 16, 2019 at 03:20 PM
Ended up just giving the wall a script and made it check if it didnt have the script before placing oh... 3 years ago me..