Search Unity

[SOLVED] ITriggerEventsJob Schedule compile error

Discussion in 'Physics for ECS' started by JamesWjRose, Apr 27, 2020.

  1. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    EDIT: Solved. I was running Visual Studio 2015 and upgraded to VS 2019 and the issue went away.
    ------------------------
    The following code is showing an issue at the line:
    Code (CSharp):
    1. return triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps);
    The call is ambiguous between the following methods or properties: IBodyPairsJobExtensions.Schedule<t>(T, Simulation, ref PhysicsWorld, JobHandle) and ICollisionEventJobExtensions.Schedule<T>(T, ISimulation, ref PhysicsWorld,JobHandle)

    I was using the code from this video:


    I tend to need an example to see how something works, so yay for YouTube/etc but the documentation is vague at best, and because of beta it seems often wrong.

    Here is my code. Any info can help

    Code (CSharp):
    1. using Unity.Entities;
    2. using System;
    3. using Unity.Jobs;
    4. using Unity.Physics;
    5. using Unity.Mathematics;
    6. using Unity.Burst;
    7. using Unity.Physics.Systems;
    8.  
    9. public class ER3D_TrafficAvoidanceSystem : JobComponentSystem
    10. {
    11.     [BurstCompile]
    12.     public struct TriggerJob : ITriggerEventsJob
    13.     {
    14.         public ComponentDataFromEntity<TestBedAutoPosition> autoPositionFromEntities;
    15.  
    16.         public void Execute(TriggerEvent triggerEvent)
    17.         {
    18.             if (autoPositionFromEntities.HasComponent(triggerEvent.Entities.EntityA))
    19.             {
    20.                 TestBedAutoPosition testBedAutoPosition = autoPositionFromEntities[triggerEvent.Entities.EntityA];
    21.                 testBedAutoPosition.height = 20;
    22.                 autoPositionFromEntities[triggerEvent.Entities.EntityA] = testBedAutoPosition;
    23.             }
    24.  
    25.             if (autoPositionFromEntities.HasComponent(triggerEvent.Entities.EntityB))
    26.             {
    27.                 TestBedAutoPosition testBedAutoPosition = autoPositionFromEntities[triggerEvent.Entities.EntityB];
    28.                 testBedAutoPosition.height = 20;
    29.                 autoPositionFromEntities[triggerEvent.Entities.EntityB] = testBedAutoPosition;
    30.             }
    31.         }
    32.     }
    33.  
    34.     private BuildPhysicsWorld buildPhysicsWorld;
    35.     private StepPhysicsWorld stepPhysicsWorld;
    36.  
    37.     protected override void OnCreate()
    38.     {
    39.         buildPhysicsWorld = World.GetOrCreateSystem<BuildPhysicsWorld>();
    40.         stepPhysicsWorld = World.GetOrCreateSystem<StepPhysicsWorld>();
    41.     }
    42.  
    43.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    44.     {
    45.         TriggerJob triggerJob = new TriggerJob
    46.         {
    47.             autoPositionFromEntities = GetComponentDataFromEntity<TestBedAutoPosition>()
    48.         };
    49.  
    50.         //Issue here:
    51.         return triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps);
    52.     }
    53. }
    EDIT: I am running Unity 2019.3.11f1 and Unity Physics 0.3.2. After posting this I also installed Havok Physics for Until version 0.2.2 When I did this the error message changed to: "The call is ambiguous between the following methods or poperties 'IHavokPairsJobExtensions.Schedule<T>(T, ISimulation, ref PhysicsWorld, JobHandle)' and 'IHavokCollisionEventsJobExtensions.Schedule<T>(T, ISimulation, ref PhysicsWorld,JobHandle)'
     
    Last edited: May 1, 2020
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    I've just tried your code locally and built it successfully. The only difference is that I was using Unity 2019.3.0f1. Interestingly, your code is no different than any other ITriggerEventsJob we have in the samples. Can you build Unity Physics Samples with your version of Unity editor?
     
  3. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    I pulled down the examples from here: https://github.com/Unity-Technologies/EntityComponentSystemSamples

    Then went looking through the code and in the TriggerVolumeAuthoring.cs - line 322, the same exception appears on the word "Schedule" The call is ambiguous between the following methods or properties: IBodyPairsJobExtensions.Schedule<t>(T, Simulation, ref PhysicsWorld, JobHandle) and ICollisionEventJobExtensions.Schedule<T>(T, ISimulation, ref PhysicsWorld,JobHandle)

    It appears, with a slightly different message in multiple places within that file, as well as RandomMotionAuthoring.cs, TriggerVolumePortalbehaviour.cs and CollisionEventImpulseAuthoring.cs, or anywhere where .Schedule is used with parameters.

    This was helpful, at least I know it's something to do with my system... exactly what I do not know yet. If I figure it out, I'll post back. If you have any ideas please let me know. Thanks kindly for you VERY quick response, while this is annoying, it's not time sensitive. You take care.
     
    petarmHavok likes this.
  4. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    Hello gang,

    I am COMPLETELY lost as to why my computer is showing these issues. I attempted to resolve this by removing Unity and Havok physics, rebooting and reinstalling just the Unity Physics. But the issue is still there. Anyone have ANY clue?

    Thanks kindly.
     
  5. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Do you get the same error if you turn off Burst Compilation?

    Also, can you try going to the Project Settings > Editor options and disable the 'Enter Play Mode Settings' option:
    PlayModeSettings.png
     
    Last edited: Apr 29, 2020
  6. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687

    Note: additional edit at bottom.

    Stevee,

    Thanks kindly for the info. However those ideas did nothing.

    * I remarked out //[BurstCompile] on the JobComponentSystem, still showing the issue
    * Went to the menu; JOBS > BURST > ENABLE COMPILATION and unchecked it
    * Went the the Editor settings (thanks SO much for the screenshot, makes it easy to find what you meant) and still the issue persists



    This is not a runtime issue, this is shown at design time.

    I did JUST now try to run the game and got the following which may be helpful. I'm going to review this info to see if it gives me a clue, but I thought you might want to see it as well. Hope your day is going well

    InvalidOperationException: The previously scheduled job ER3D_TrafficAvoidanceSystem:TriggerJob writes to the NativeArray TriggerJob.UserJobData.autoPositionFromEntities. You are trying to schedule a new job TestBedHoverSystem:AutoDriveHop, which writes to the same NativeArray (via AutoDriveHop.Iterator). To guarantee safety, you must include ER3D_TrafficAvoidanceSystem:TriggerJob as a dependency of the newly scheduled job.
    Unity.Entities.JobForEachExtensions.Schedule (System.Void* fullData, Unity.Collections.NativeArray`1[T] prefilterData, System.Int32 unfilteredLength, System.Int32 innerloopBatchCount, System.Boolean isParallelFor, System.Boolean isFiltered, Unity.Entities.JobForEachExtensions+JobForEachCache& cache, System.Void* deferredCountData, Unity.Jobs.JobHandle dependsOn, Unity.Jobs.LowLevel.Unsafe.ScheduleMode mode) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/IJobForEach.cs:415)
    Unity.Entities.JobForEachExtensions.ScheduleInternal_CC[T] (T& jobData, Unity.Entities.ComponentSystemBase system, Unity.Entities.EntityQuery query, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn, Unity.Jobs.LowLevel.Unsafe.ScheduleMode mode) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/IJobForEach.gen.cs:1878)
    Unity.Entities.JobForEachExtensions.Run[T] (T jobData, Unity.Entities.ComponentSystemBase system, Unity.Jobs.JobHandle dependsOn) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/IJobForEach.gen.cs:1038)
    TestBedHoverSystem.OnUpdate (Unity.Jobs.JobHandle inputDeps) (at Assets/HBC/Scripts/TestBedHoverSystem.cs:18)
    Unity.Entities.JobComponentSystem.Update () (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/JobComponentSystem.cs:129)
    Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
    UnityEngine.Debug:LogException(Exception)
    Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/Stubs/Unity/Debug.cs:19)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:138)
    Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:114)
    Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
    Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ScriptBehaviourUpdateOrder.cs:200)

    ------------------------------------

    The error does not seem to be anything to do with the issue I am having with .Schedule

    I double checked the Unity examples (as Petarm mentioned above) to ensure that the same issue is there. It is, see line 98


    So there is some issue on my computer, but for the life of me I have NO clue on what could cause this.

    ------------------------------------

    EDIT 2: Installed 2019.3.12, which was made available today, and the issue is still there. Didn't think a Unity upgrade would fix it... but just in case. (drats)

    ------------------------------------

    EDIT 3: I installed Unity 2019.3.12 on my laptop, opened the Unity example above and I do not get that issue. So what the hell is wrong with my development machine that causes the error? arrrrrgggg!
     
    Last edited: Apr 30, 2020
  7. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    So... do I need to beg? Because I will beg, I'm not above it.

    Why would one computer be throwing this issue?

    I am also getting an exception within World.cs (see https://forum.unity.com/threads/new-exception-with-latest-unity-and-dots-components.880087/ for details) and when I attempt to compile in Visual Studio I get a massive list of exceptions (see below)

    So... something is wrong, and I have spend the better part of the week attempting to figure this out, alone. HELP. (please) I know this is beta, and I have worked with beta software for nearly 30 years (WinNT in 92) so I get it.... but I am frustrated and don't know what to do.

    Please help.

    EDIT: despite all of these exceptions, I can run the game/scene... so yea, there is something very odd happening
     
  8. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Given that you downloaded a clean version of the Unity Physics samples and still had the problems (and have things working on another machine) makes me wonder if there is something wrong with the installation of Unity itself? But then, you did install a new version of Unity already.
    So I wonder then if this about the game development components of Visual Studio rather than Unity itself? Is it worth reinstalling them from the Visual Studio installer? upload_2020-5-1_17-26-36.png
     
  9. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    Do you mean reinstall Visual Studio, or the Unity components via NuGet? If so, a url to the specfic package would be helpful so I don't install the wrong components. I have never installed Unity components from VS, so please pardon the ignorance.
     
    Last edited: May 1, 2020
  10. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    I generally use the Visual Studio Installer. You can modify your installation and untick the 'Game Development with Unity' option. I'm mostly thinking of the 'Manual Installation' section on this page.
     
    oAzuehT and JamesWjRose like this.
  11. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    Thanks. I'll give it a try shortly.
     
  12. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    YAY! Success. I was running VS 2015 and upgraded to 2019 and that resolved the conflict. Seems very odd that the IDE would cause two of Unity's functions to conflict... but hey, it's working.

    Thank you very much for your time. Have a great weekend
     
    oAzuehT and steveeHavok like this.