Prefab spawning around gameobject

    0

    0

    vino1807

    /// <summary>
      /// Fait apparaitre un préfab aléatoirement autour d'un object. 
      /// </summary>
      public void SpawnObject(int Quantity)
      {
        for (int x = 0; x < Quantity; x++)
        {
    
          float angle = Random.Range(0, 361);
          Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.up);
          Vector3 direction = rotation * Vector3.forward;
    
          Vector3 position = this.transform.position + (direction * drop_Distance);
          Instantiate(Prefab, position, rotation);
        }
    
    
      }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.