1. Code:
     [ChatCommand("chest")]
            private void cmdChatairbox(BasePlayer player, string command, string[] args)
            {
                string name = "assets/prefabs/misc/supply drop/supply_drop.prefab";
                chest.x = 555;
                chest.y = 44; <---- not ground
                chest.z = 555;
                BaseEntity entity = GameManager.server.CreateEntity(name, chest);
                entity.Spawn(true);
    }
    
    But how to spawn the entity on the ground??
     
  2. I'd say use a ray cast something along the lines with hitting this layer.
    floor = UnityEngine.LayerMask.GetMask("Terrain", "World");
    I'm no expert at that though
     
  3. Wulf

    Wulf Community Admin

    There's a working example in my Hide and Seek plugin if you'd like as well.
     
  4. @Wulf where abouts in the plugin is the working example?
     
  5. Code:
            private static LayerMask GROUND_MASKS = LayerMask.GetMask("Terrain", "World", "Construction");
    //Credit: Wulf
            static Vector3 GetGroundPosition(Vector3 sourcePos)
            {
                RaycastHit hitInfo;            if (Physics.Raycast(sourcePos, Vector3.down, out hitInfo, GROUND_MASKS))
                {
                    sourcePos.y = hitInfo.point.y;
                }
                sourcePos.y = Mathf.Max(sourcePos.y, TerrainMeta.HeightMap.GetHeight(sourcePos));
                return sourcePos;
            }
    Input the x and z coords in a vector 3 and it will return with the ground height
     
  6. Thanks!