Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Assets/Scripts/Terrain/World.cs(136,56): error CS1501: No overload for method 'Drop' takes 2 argumen

Discussion in 'Scripting' started by Rachzella, Aug 16, 2019.

  1. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    So i have been following a tuttorial on youtube and everything is working great but this one thing. it keeps saying that No Overload for method 'Drop' i tried to fix it but i can't get it fixed. it might be messing with another script, i can't tell. anyone know how to fix it?

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Object = UnityEngine.Object;
    5.  
    6. public interface IWorld
    7. {
    8. }
    9.  
    10. public class World : IWorld
    11. {
    12.     private readonly ITerrainGenerator m_TerrainGenerator;
    13.     private readonly WorldData m_WorldData;
    14.     private readonly ILightProcessor m_LightProcessor;
    15.     private readonly IMeshGenerator m_MeshGenerator;
    16.     private readonly IWorldDecorator m_WorldDecorator;
    17.  
    18.  
    19.     public World(WorldData worldData, ITerrainGenerator terrainGenerator, ILightProcessor lightProcessor,
    20.                  IMeshGenerator meshGenerator, IWorldDecorator worldDecorator)
    21.     {
    22.         m_WorldData = worldData;
    23.         m_LightProcessor = lightProcessor;
    24.         m_MeshGenerator = meshGenerator;
    25.         m_WorldDecorator = worldDecorator;
    26.         m_TerrainGenerator = terrainGenerator;
    27.     }
    28.  
    29.     public void InitializeGridChunks()
    30.     {
    31.         m_WorldData.InitializeGridChunks();
    32.     }
    33.  
    34.     public void GenerateWorld()
    35.     {
    36.         List<Chunk> allVisibleChunks = m_WorldData.AllVisibleChunks;
    37.         List<Chunk> allChunks = m_WorldData.AllChunks;
    38.         DateTime start = DateTime.Now;
    39.  
    40.         GenerateTerrain(allChunks);
    41.  
    42.         Debug.Log(DateTime.Now - start);
    43.  
    44.         GenerateWorldDecorations(allVisibleChunks);
    45.         Debug.Log(DateTime.Now - start);
    46.  
    47.         GenerateLighting(allVisibleChunks);
    48.         Debug.Log(DateTime.Now - start);
    49.         allVisibleChunks.Sort(ChunksComparedByDistanceFromMapCenter);
    50.         m_MeshGenerator.GenerateMeshes(allVisibleChunks);
    51.         ClearRegenerationStatus(allChunks);
    52.     }
    53.  
    54.     private void GenerateWorldDecorations(List<Chunk> chunks)
    55.     {
    56.         m_WorldDecorator.GenerateWorldDecorations(chunks);
    57.     }
    58.  
    59.  
    60.     private static void ClearRegenerationStatus(IEnumerable<Chunk> chunks)
    61.     {
    62.         foreach (Chunk chunk in chunks)
    63.         {
    64.             chunk.NeedsRegeneration = false;
    65.         }
    66.     }
    67.  
    68.     private void GenerateLighting(List<Chunk> chunks)
    69.     {
    70.         m_LightProcessor.LightChunks(chunks);
    71.     }
    72.  
    73.     private void GenerateTerrain(List<Chunk> chunks)
    74.     {
    75.         m_TerrainGenerator.GenerateChunkTerrain(chunks);
    76.     }
    77.  
    78.  
    79.     // this is the actual comparison method that compares them by distance
    80.     private int ChunksComparedByDistanceFromMapCenter(Chunk firstChunk,
    81.                                                       Chunk secondChunk)
    82.     {
    83.         Vector3 mapCenter = new Vector3(m_WorldData.CenterChunkX, m_WorldData.CenterChunkY, 0);
    84.         return Vector3.Distance(
    85.             new Vector3(firstChunk.X, firstChunk.Y, firstChunk.Z), mapCenter).
    86.             CompareTo(
    87.                 (int) Vector3.Distance(new Vector3(secondChunk.X, secondChunk.Y, secondChunk.Z), mapCenter));
    88.     }
    89.  
    90.  
    91.     // Regenerates the target chunk first, followed by any others that need regeneration.
    92.     public void RegenerateChunks(int chunkX, int chunkY, int chunkZ)
    93.     {
    94.         List<Chunk> chunksNeedingRegeneration = m_WorldData.ChunksNeedingRegeneration;
    95.         if (chunksNeedingRegeneration.Count == 0)
    96.         {
    97.             return;
    98.         }
    99.  
    100.         Chunk targetChunk = m_WorldData.Chunks[chunkX, chunkY, chunkZ];
    101.         if (chunksNeedingRegeneration.Contains(targetChunk))
    102.         {
    103.             chunksNeedingRegeneration.Remove(targetChunk);
    104.             chunksNeedingRegeneration.Insert(0, targetChunk);
    105.         }
    106.  
    107.         RegenerateChunks(chunksNeedingRegeneration);
    108.     }
    109.  
    110.     public void RegenerateChunks()
    111.     {
    112.         List<Chunk> chunksNeedingRegeneration = m_WorldData.ChunksNeedingRegeneration;
    113.         if (chunksNeedingRegeneration.Count == 0)
    114.         {
    115.             return;
    116.         }
    117.  
    118.         RegenerateChunks(chunksNeedingRegeneration);
    119.     }
    120.  
    121.     private void RegenerateChunks(List<Chunk> chunksNeedingRegeneration)
    122.     {
    123.         chunksNeedingRegeneration.ForEach(chunk => Debug.Log("Regenerating " + chunk));
    124.         m_LightProcessor.LightChunks(chunksNeedingRegeneration);
    125.         m_MeshGenerator.GenerateMeshes(chunksNeedingRegeneration);
    126.         ClearRegenerationStatus(chunksNeedingRegeneration);
    127.     }
    128.  
    129.     public void RemoveBlockAt(IntVect hitPoint)
    130.     {
    131.         Block block = m_WorldData.GetBlock(hitPoint.X, hitPoint.Y, hitPoint.Z);
    132.         Debug.Log(block.Type);
    133.         GameObject BlockDrop;
    134.  
    135.         BlockDrop = MonoBehaviour.Instantiate(Resources.Load("Drop", typeof(GameObject)), new Vector3(hitPoint.X, hitPoint.Y, hitPoint.Z), Quaternion.identity) as GameObject;
    136.         BlockDrop.gameObject.GetComponent<Droppings>().Drop(new Vector3(hitPoint.X, hitPoint.Y, hitPoint.Z), block.Type);
    137.  
    138.         m_WorldData.SetBlockTypeWithRegeneration(hitPoint.X, hitPoint.Y, hitPoint.Z, BlockType.Air);
    139.         m_LightProcessor.RecalculateLightingAround(hitPoint.X, hitPoint.Y, hitPoint.Z);
    140.         RegenerateChunks(hitPoint.X / m_WorldData.ChunkBlockHeight,
    141.                          hitPoint.Y / m_WorldData.ChunkBlockHeight,
    142.                          hitPoint.Z / m_WorldData.ChunkBlockDepth);
    143.     }
    144.  
    145.     public void FireNukeAt(IntVect hitPoint, Ray ray)
    146.     {
    147.         Debug.Log(hitPoint + " - " + ray);
    148.         float xInc = hitPoint.X;
    149.         float yInc = hitPoint.Y;
    150.         float zInc = hitPoint.Z;
    151.         for (int distance = 0; distance <= 10; distance++)
    152.         {
    153.             xInc += ray.direction.x;
    154.             yInc += ray.direction.y;
    155.             zInc += ray.direction.z;
    156.             for (int numBlocks = 0; numBlocks < 10; numBlocks++)
    157.             {
    158.                 int blockX = (int) (UnityEngine.Random.insideUnitSphere.x * 3 + xInc);
    159.                 int blockY = (int) (UnityEngine.Random.insideUnitSphere.y * 3 + yInc);
    160.                 int blockZ = (int) (UnityEngine.Random.insideUnitSphere.z * 3 + zInc);
    161.                 m_WorldData.SetBlockTypeWithRegeneration(blockX, blockY, blockZ, BlockType.Air);
    162.             }
    163.         }
    164.     }
    165.  
    166.     private int m_DiggingAmount = 100;
    167.     private IntVect m_DiggingLocation;
    168.     private DateTime m_LastDigTime;
    169.     private readonly TimeSpan m_DigDuration = TimeSpan.FromSeconds(0.25);
    170.     public readonly Queue<Vector3> Diggings = new Queue<Vector3>();
    171.  
    172.     public void Dig(IntVect targetLocation, Vector3 hitPoint)
    173.     {
    174.         DateTime currentDigTime = DateTime.Now;
    175.         if (targetLocation != m_DiggingLocation)
    176.         {
    177.             m_DiggingAmount = 100;
    178.             m_DiggingLocation = targetLocation;
    179.             m_LastDigTime = currentDigTime;
    180.             Diggings.Enqueue(hitPoint);
    181.         }
    182.         else
    183.         {
    184.             if (currentDigTime - m_LastDigTime > m_DigDuration)
    185.             {
    186.                 Diggings.Enqueue(hitPoint);
    187.                 m_DiggingAmount = m_DiggingAmount - 25;
    188.                 m_LastDigTime = currentDigTime;
    189.                
    190.                 if (m_DiggingAmount <=0)
    191.                 {
    192.                     RemoveBlockAt(targetLocation);
    193.                     m_DiggingAmount = 100;
    194.                 }
    195.             }
    196.         }
    197.     }
    198.  
    199.     public static void DestroyChunk(Chunk chunk)
    200.     {
    201.         if (chunk.ChunkPrefab != null)
    202.         {
    203.             MeshFilter meshFilter = chunk.ChunkPrefab.GetComponent<MeshFilter>();
    204.             meshFilter.mesh.Clear();
    205.             Object.Destroy(meshFilter.mesh);
    206.             meshFilter.mesh = null;
    207.             Object.Destroy(meshFilter);
    208.             Object.Destroy(chunk.ChunkPrefab.gameObject);
    209.             chunk.ChunkPrefab = null;
    210.         }
    211.         chunk = null;
    212.     }
    213. }
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,615
    Look at the code for the "Droppings" class. What parameters does Drop take?
     
  3. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    if you mean the script for it it's this
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Droppings : MonoBehaviour  {
    6.     Vector3 Position;
    7.         public List<Texture2D> Blocks = new List<Texture2D>();
    8.         public List<Texture2D> BlocksSeperate = new List<Texture2D>();
    9.  
    10.     public void Drop(BlockType type)
    11.     {
    12.  
    13.        ///Use this section to add leaves that do not drop material
    14.  
    15.         Position = GameObject.FindGameObjectWithTag("Player").transform.position;
    16.         if (type == BlockType.Leaves)
    17.         {
    18.             Destroy(this.gameObject);
    19.         }
    20.         if (type == BlockType.TopSoil || type == BlockType.Log)
    21.         {
    22.             Destroy(this.transform.GetChild(1).gameObject);
    23.              AwakeItemSeperate(type);
    24.         }
    25.         else
    26.         {
    27.             Destroy(this.transform.GetChild(0).gameObject);
    28.             AwakeItemFull(type);
    29.  
    30.         }
    31.         this.transform.position = Position;
    32.         this.transform.GetChild(0).transform.position = this.transform.position;
    33.     }
    34.     //// These are items that do drop bellow
    35.     public void AwakeItemFull(BlockType Type)
    36.     {
    37.         if (Type == BlockType.Stone)
    38.         {
    39.             this.transform.GetChild(1).gameObject.GetComponent<Renderer>().material.mainTexture = Blocks[0];
    40.         }
    41.         if (Type == BlockType.Dirt)
    42.         {
    43.             this.transform.GetChild(1).gameObject.GetComponent<Renderer>().material.mainTexture = Blocks[1];
    44.         }
    45.         if (Type == BlockType.Leaves)
    46.         {
    47.             this.transform.GetChild(1).gameObject.GetComponent<Renderer>().material.mainTexture = Blocks[2];
    48.         }
    49.     }
    50.     //// These are items that do drop a different material.
    51.     public void AwakeItemSeperate(BlockType Type)
    52.     {
    53.         if (Type == BlockType.Log)
    54.         {
    55.             this.transform.GetChild(0).gameObject.GetComponent<Renderer>().material.mainTexture = BlocksSeperate[0];
    56.         }
    57.         if (Type == BlockType.TopSoil)
    58.         {
    59.             this.transform.GetChild(0).gameObject.GetComponent<Renderer>().material.mainTexture = BlocksSeperate[1];
    60.         }
    61.     }
    62. }
     
  4. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Because you declared method with 1 parameter

    Code (CSharp):
    1. public void Drop(BlockType type)
    and calling it with 2.

    Code (CSharp):
    1. .Drop(new Vector3(hitPoint.X, hitPoint.Y, hitPoint.Z), block.Type);
    2.  
    The error message says exactly this.
     
  5. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,615
    So there you can see that Drop takes only one parameter, which is the BlockType. When you call Drop in your World class, you are trying to pass a Vector3 and a BlockType for some reason.
     
  6. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    I'm not a code specialist. and still getting to know unity.
    I'm not a code specialist. i'm still learning and no idea how to fix it even knowing that. sorry. what do i need to change or remove?
     
  7. Deleted User

    Deleted User

    Guest

    So, either you add a parameter to
    Code (CSharp):
    1. public void Drop(BlockType type)
    or you remove the new Vector3() in
    Code (CSharp):
    1. .Drop(new Vector3(hitPoint.X, hitPoint.Y, hitPoint.Z), block.Type);
    Method overloading tutorial: https://learn.unity.com/tutorial/method-overloading#
     
  8. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    I can't remove the vector cause it only results in more errors and i feel so dumb right now that i don't know how to adda a parameter. even after watching the tutorial you send along.
     
  9. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    What does it look like after you remove the vector and what are the errors? I'm certain those are just minor syntax errors that are easily fixable.

    Don't bother adding a parameter to the function definition - if the function doesn't use the parameter, then there' no point in having it there.
     
  10. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,615
    What errors? You probably just made a mistake when changing the function call.

    Presumably, the line in your World class that looks like:
    Code (csharp):
    1. BlockDrop.gameObject.GetComponent<Droppings>().Drop(new Vector3(hitPoint.X, hitPoint.Y, hitPoint.Z), block.Type);
    Should look like:
    Code (csharp):
    1. BlockDrop.gameObject.GetComponent<Droppings>().Drop(block.Type);
     
  11. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    assets/Scripts/Terrain/World.cs(136,96): error CS1513: } expected
    2 times
     
  12. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    And we need to see the code too.
     
  13. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    Now it's stugling with the position context. The scripts are supposed to drop a entity once it breaks on locations. i'm sure it needs vector3 to work as intened. but it's strange cause i followed the complete code and everything is the same. onlt he dind't get this error. or problem.
     
  14. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Well, it's fairly simple thing so I try to explain. When you write code, you write procedures. Basically procedure (function, method, whatever you call it) is a set of actions what must be sequntially executed on some data. That data is provided as parameters. If you wrote procedure function for 1 parameter (drop kind) in your case, you must use it with 1 parameter. Either stop passing it a vector, or write another alike procedure for 2 parameters.
     
  15. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Object = UnityEngine.Object;
    5.  
    6. public interface IWorld
    7. {
    8. }
    9.  
    10. public class World : IWorld
    11. {
    12.     private readonly ITerrainGenerator m_TerrainGenerator;
    13.     private readonly WorldData m_WorldData;
    14.     private readonly ILightProcessor m_LightProcessor;
    15.     private readonly IMeshGenerator m_MeshGenerator;
    16.     private readonly IWorldDecorator m_WorldDecorator;
    17.  
    18.  
    19.     public World(WorldData worldData, ITerrainGenerator terrainGenerator, ILightProcessor lightProcessor,
    20.                  IMeshGenerator meshGenerator, IWorldDecorator worldDecorator)
    21.     {
    22.         m_WorldData = worldData;
    23.         m_LightProcessor = lightProcessor;
    24.         m_MeshGenerator = meshGenerator;
    25.         m_WorldDecorator = worldDecorator;
    26.         m_TerrainGenerator = terrainGenerator;
    27.     }
    28.  
    29.     public void InitializeGridChunks()
    30.     {
    31.         m_WorldData.InitializeGridChunks();
    32.     }
    33.  
    34.     public void GenerateWorld()
    35.     {
    36.         List<Chunk> allVisibleChunks = m_WorldData.AllVisibleChunks;
    37.         List<Chunk> allChunks = m_WorldData.AllChunks;
    38.         DateTime start = DateTime.Now;
    39.  
    40.         GenerateTerrain(allChunks);
    41.  
    42.         Debug.Log(DateTime.Now - start);
    43.  
    44.         GenerateWorldDecorations(allVisibleChunks);
    45.         Debug.Log(DateTime.Now - start);
    46.  
    47.         GenerateLighting(allVisibleChunks);
    48.         Debug.Log(DateTime.Now - start);
    49.         allVisibleChunks.Sort(ChunksComparedByDistanceFromMapCenter);
    50.         m_MeshGenerator.GenerateMeshes(allVisibleChunks);
    51.         ClearRegenerationStatus(allChunks);
    52.     }
    53.  
    54.     private void GenerateWorldDecorations(List<Chunk> chunks)
    55.     {
    56.         m_WorldDecorator.GenerateWorldDecorations(chunks);
    57.     }
    58.  
    59.  
    60.     private static void ClearRegenerationStatus(IEnumerable<Chunk> chunks)
    61.     {
    62.         foreach (Chunk chunk in chunks)
    63.         {
    64.             chunk.NeedsRegeneration = false;
    65.         }
    66.     }
    67.  
    68.     private void GenerateLighting(List<Chunk> chunks)
    69.     {
    70.         m_LightProcessor.LightChunks(chunks);
    71.     }
    72.  
    73.     private void GenerateTerrain(List<Chunk> chunks)
    74.     {
    75.         m_TerrainGenerator.GenerateChunkTerrain(chunks);
    76.     }
    77.  
    78.  
    79.     // this is the actual comparison method that compares them by distance
    80.     private int ChunksComparedByDistanceFromMapCenter(Chunk firstChunk,
    81.                                                       Chunk secondChunk)
    82.     {
    83.         Vector3 mapCenter = new Vector3(m_WorldData.CenterChunkX, m_WorldData.CenterChunkY, 0);
    84.         return Vector3.Distance(
    85.             new Vector3(firstChunk.X, firstChunk.Y, firstChunk.Z), mapCenter).
    86.             CompareTo(
    87.                 (int) Vector3.Distance(new Vector3(secondChunk.X, secondChunk.Y, secondChunk.Z), mapCenter));
    88.     }
    89.  
    90.  
    91.     // Regenerates the target chunk first, followed by any others that need regeneration.
    92.     public void RegenerateChunks(int chunkX, int chunkY, int chunkZ)
    93.     {
    94.         List<Chunk> chunksNeedingRegeneration = m_WorldData.ChunksNeedingRegeneration;
    95.         if (chunksNeedingRegeneration.Count == 0)
    96.         {
    97.             return;
    98.         }
    99.  
    100.         Chunk targetChunk = m_WorldData.Chunks[chunkX, chunkY, chunkZ];
    101.         if (chunksNeedingRegeneration.Contains(targetChunk))
    102.         {
    103.             chunksNeedingRegeneration.Remove(targetChunk);
    104.             chunksNeedingRegeneration.Insert(0, targetChunk);
    105.         }
    106.  
    107.         RegenerateChunks(chunksNeedingRegeneration);
    108.     }
    109.  
    110.     public void RegenerateChunks()
    111.     {
    112.         List<Chunk> chunksNeedingRegeneration = m_WorldData.ChunksNeedingRegeneration;
    113.         if (chunksNeedingRegeneration.Count == 0)
    114.         {
    115.             return;
    116.         }
    117.  
    118.         RegenerateChunks(chunksNeedingRegeneration);
    119.     }
    120.  
    121.     private void RegenerateChunks(List<Chunk> chunksNeedingRegeneration)
    122.     {
    123.         chunksNeedingRegeneration.ForEach(chunk => Debug.Log("Regenerating " + chunk));
    124.         m_LightProcessor.LightChunks(chunksNeedingRegeneration);
    125.         m_MeshGenerator.GenerateMeshes(chunksNeedingRegeneration);
    126.         ClearRegenerationStatus(chunksNeedingRegeneration);
    127.     }
    128.  
    129.     public void RemoveBlockAt(IntVect hitPoint)
    130.     {
    131.         Block block = m_WorldData.GetBlock(hitPoint.X, hitPoint.Y, hitPoint.Z);
    132.         Debug.Log(block.Type);
    133.         GameObject BlockDrop;
    134.  
    135.         BlockDrop = MonoBehaviour.Instantiate(Resources.Load("Droppings", typeof(GameObject)), Quaternion.identity) as GameObject;
    136.         BlockDrop.gameObject.GetComponent<Droppings>().Drop(block.Type);
    137.  
    138.         m_WorldData.SetBlockTypeWithRegeneration(hitPoint.X, hitPoint.Y, hitPoint.Z, BlockType.Air);
    139.         m_LightProcessor.RecalculateLightingAround(hitPoint.X, hitPoint.Y, hitPoint.Z);
    140.         RegenerateChunks(hitPoint.X / m_WorldData.ChunkBlockHeight,
    141.                          hitPoint.Y / m_WorldData.ChunkBlockHeight,
    142.                          hitPoint.Z / m_WorldData.ChunkBlockDepth);
    143.     }
    144.  
    145.     public void FireNukeAt(IntVect hitPoint, Ray ray)
    146.     {
    147.         Debug.Log(hitPoint + " - " + ray);
    148.         float xInc = hitPoint.X;
    149.         float yInc = hitPoint.Y;
    150.         float zInc = hitPoint.Z;
    151.         for (int distance = 0; distance <= 10; distance++)
    152.         {
    153.             xInc += ray.direction.x;
    154.             yInc += ray.direction.y;
    155.             zInc += ray.direction.z;
    156.             for (int numBlocks = 0; numBlocks < 10; numBlocks++)
    157.             {
    158.                 int blockX = (int) (UnityEngine.Random.insideUnitSphere.x * 3 + xInc);
    159.                 int blockY = (int) (UnityEngine.Random.insideUnitSphere.y * 3 + yInc);
    160.                 int blockZ = (int) (UnityEngine.Random.insideUnitSphere.z * 3 + zInc);
    161.                 m_WorldData.SetBlockTypeWithRegeneration(blockX, blockY, blockZ, BlockType.Air);
    162.             }
    163.         }
    164.     }
    165.  
    166.     private int m_DiggingAmount = 100;
    167.     private IntVect m_DiggingLocation;
    168.     private DateTime m_LastDigTime;
    169.     private readonly TimeSpan m_DigDuration = TimeSpan.FromSeconds(0.25);
    170.     public readonly Queue<Vector3> Diggings = new Queue<Vector3>();
    171.  
    172.     public void Dig(IntVect targetLocation, Vector3 hitPoint)
    173.     {
    174.         DateTime currentDigTime = DateTime.Now;
    175.         if (targetLocation != m_DiggingLocation)
    176.         {
    177.             m_DiggingAmount = 100;
    178.             m_DiggingLocation = targetLocation;
    179.             m_LastDigTime = currentDigTime;
    180.             Diggings.Enqueue(hitPoint);
    181.         }
    182.         else
    183.         {
    184.             if (currentDigTime - m_LastDigTime > m_DigDuration)
    185.             {
    186.                 Diggings.Enqueue(hitPoint);
    187.                 m_DiggingAmount = m_DiggingAmount - 25;
    188.                 m_LastDigTime = currentDigTime;
    189.                
    190.                 if (m_DiggingAmount <=0)
    191.                 {
    192.                     RemoveBlockAt(targetLocation);
    193.                     m_DiggingAmount = 100;
    194.                 }
    195.             }
    196.         }
    197.     }
    198.  
    199.     public static void DestroyChunk(Chunk chunk)
    200.     {
    201.         if (chunk.ChunkPrefab != null)
    202.         {
    203.             MeshFilter meshFilter = chunk.ChunkPrefab.GetComponent<MeshFilter>();
    204.             meshFilter.mesh.Clear();
    205.             Object.Destroy(meshFilter.mesh);
    206.             meshFilter.mesh = null;
    207.             Object.Destroy(meshFilter);
    208.             Object.Destroy(chunk.ChunkPrefab.gameObject);
    209.             chunk.ChunkPrefab = null;
    210.         }
    211.         chunk = null;
    212.     }
    213. }
    it has so many parts that use vector3, position and hitpoint. or any location indicator.
     
  16. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    So how or what would that look like? sorry for asking.
     
  17. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,615
    Look at the first line of code in the Drop function:

    Code (csharp):
    1.  
    2. Position = GameObject.FindGameObjectWithTag("Player").transform.position;
    3.  
    You see? You don't have to pass in a position to the function because it is using that position up there. The Drop function is trying to find the position itself. Looks like it's trying to use the player's position. By the way, do you have an object in your scene that has the "Player" tag?

    By the way, if this tutorials code isn't working and you're sure that you copied it all correctly, than you may need to contact the author of tutorial for clarification.
     
  18. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Let's give it a try. You have now this:
    Code (CSharp):
    1. public void Drop(DropType type) {
    2.    .... drop some items into scene ....
    3. }
    4.  
    5. // and somewhere else:
    6.  
    7. Droppings.Drop(position, itemType)
    you need either to add

    Code (CSharp):
    1. public void Drop(Vector3 position, DropType dropType) {
    2.   .. drops items into scene at given position ...
    3. }
    or remove

    Code (CSharp):
    1.  
    2. Droppings.Drop(itemType)
    I think you need to remove, but it just a wild guess.
     
  19. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    Yes there is a object labelled as "Player" And i don't think he'll reply. that was uploaded 2 years ago. so i doubt i can get that way.
     
  20. Rachzella

    Rachzella

    Joined:
    Oct 9, 2015
    Posts:
    78
    And where in the script and which one? i tried replacing the
    Code (CSharp):
    1. public Drop(BlockType type)
    in the dropping.cs but i don't see another public drop in world.cs. the place where the issues form is as RemoveBlockAt
    Code (CSharp):
    1. public void RemoveBlockAt(IntVect hitPoint)
    2.     {
    3.         Block block = m_WorldData.GetBlock(hitPoint.X, hitPoint.Y, hitPoint.Z);
    4.         Debug.Log(block.Type);
    5.         GameObject BlockDrop;
    6.  
    7.         BlockDrop = MonoBehaviour.Instantiate(Resources.Load("Droppings", typeof(GameObject)), new Vector3(hitPoint.X, hitPoint.Y, hitPoint.Z), Quaternion.identity) as GameObject;
    8.         BlockDrop.gameObject.GetComponent<Droppings>().Drop(new Vector3(hitPoint.X, hitPoint.Y, hitPoint.Z), block.Type);
    9.  
    10.         m_WorldData.SetBlockTypeWithRegeneration(hitPoint.X, hitPoint.Y, hitPoint.Z, BlockType.Air);
    11.         m_LightProcessor.RecalculateLightingAround(hitPoint.X, hitPoint.Y, hitPoint.Z);
    12.         RegenerateChunks(hitPoint.X / m_WorldData.ChunkBlockHeight,
    13.                          hitPoint.Y / m_WorldData.ChunkBlockHeight,
    14.                          hitPoint.Z / m_WorldData.ChunkBlockDepth);
    15.     }
    I spend a fair time working on everything. i don't want to either redo all of it or just abandon it.