Search Unity

Need help spawning an LOD group

Discussion in 'Scripting' started by gannonknight0, Oct 18, 2019.

  1. gannonknight0

    gannonknight0

    Joined:
    Jun 25, 2019
    Posts:
    2
    I am trying to procedurally spawn a LOD group, but when I put it as my GameObject to be copied, it doesn't work. I have verified that it works with a normal GameObject. I cannot figure out how to call on an LOD group instead of a GameObject. Any help appreciated.



    My Code:



    Code (CSharp):
    1. using System.Collections;
    2.  
    3. using System.Collections.Generic;
    4.  
    5. using UnityEngine;
    6.  
    7.  
    8.  
    9. public class Spreader : MonoBehaviour
    10.  
    11. {
    12.  
    13.  
    14.  
    15.  
    16.  
    17. public GameObject itemToSpread;
    18.  
    19. public int xvalue = 7;
    20.  
    21. public int yvalue = 8;
    22.  
    23. public int zvalue = 10;
    24.  
    25. public int zvalue2 = 15;
    26.  
    27.  
    28.  
    29.  
    30.  
    31. void Start()
    32.  
    33. {
    34.  
    35. spreadItems();
    36.  
    37. }
    38.  
    39.  
    40.  
    41. void spreadItems ()
    42.  
    43. {
    44.  
    45. Vector3 randPosition = new Vector3 (Random.Range(-xvalue, xvalue), Random.Range(-yvalue, yvalue), Random.Range(zvalue, zvalue2));
    46.  
    47.  
    48.  
    49. GameObject clone = Instantiate(itemToSpread, randPosition, Quaternion.identity);
    50.  
    51.  
    52.  
    53. Debug.Log("Spawned");
    54.  
    55. }
    56.  
    57. void Update()
    58.  
    59. {
    60.  
    61. }
    62.  
    63. }
     
    Last edited: Oct 18, 2019