Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to Fix Error! CS0052: Inconsistent accessibility on NativeArray! Help pls

Discussion in 'Scripting' started by Myler133, Jun 23, 2022.

  1. Myler133

    Myler133

    Joined:
    Jun 23, 2022
    Posts:
    3
    Hello, i'm super new to unity 1 and c# 1 week and i'm actually following a Youtube video tutorial on how to make a TowerDefense game, the thing is i'm getting a error that i do not know how to resolve.

    "
    Code (CSharp):
    1. public struct MoveEnemiesJob : IJobParallelForTransform
    2. {
    3.     [NativeDisableParallelForRestriction]
    4.     public NativeAray<Vector3> NodePositions;
    5.  
    6.     [NativeDisableParallelForRestriction]
    7.     public NativeAray<float> EnemySpeed;
    8.  
    9.     [NativeDisableParallelForRestriction]
    10.     public NativeAray<int> NodeIndex;
    11.  
    12.     public float deltaTime;
    13.  
    14.     public void Execute(int index, TransformAccess transform)
    15.     {
    16.         if (NodeIndex[index] < NodePositions.Length)
    17.         {
    18.         }
    19.         Vector3 PositionToMoveTo = NodePositions[NodeIndex[index]];
    20.         transform.position = Vector3.MoveTowards(transform.position, PositionToMoveTo, EnemySpeed[index] * deltaTime);
    21.  
    22.         if(transform.position == PositionToMoveTo)
    23.         {
    24.             NodeIndex[index]++;
    25.         }
    26.      
    27.     }
    28.  
    29. }
    i'm getting this 3 errors

    1 *
    Assets\Classes\Game\GameLoopManager.cs(132,32): error CS0052: Inconsistent accessibility: field type 'NativeAray<Vector3>' is less accessible than field 'MoveEnemiesJob.NodePositions'

    2 *
    Assets\Classes\Game\GameLoopManager.cs(135,30): error CS0052: Inconsistent accessibility: field type 'NativeAray<float>' is less accessible than field 'MoveEnemiesJob.EnemySpeed'

    3*
    Assets\Classes\Game\GameLoopManager.cs(138,28): error CS0052: Inconsistent accessibility: field type 'NativeAray<int>' is less accessible than field 'MoveEnemiesJob.NodeIndex'
     
  2. Myler133

    Myler133

    Joined:
    Jun 23, 2022
    Posts:
    3
    the video i'm using in this case is

    16:10
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    This sounds like a jobs thing, and I'm not even sure of the jobs subsystem stability or state... is it still preview or release? Does this video use the preview or the release? Try and match whatever they're using I guess, but it's also likely tightly bound to the version of Unity you're on.

    If you just want to make a TD game, the last thing you need is the jobs system... find a tutorial that just does it "vanilla," none of this uber-high-tech future stuff. If you need to then have ten billion units attacking at once, then yeah, perhaps look into jobs.
     
  4. Myler133

    Myler133

    Joined:
    Jun 23, 2022
    Posts:
    3
    Yeah it's from unity jobs, that's in resources now, i've had a hard time to discover that kkk, but thank you for the tip, the game is just 1 map 50 enemies and 50 waves each one using one enemy, so not that many units probably nothing above 500 hundred at the same time