Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Dr_SuiuS · Jan 09, 2021 at 01:21 PM · errorphysicserror messageerror-messagedots

Must include HavokSimulation:SyncJob as a dependency

I am trying to make limit my player's jumping when he is not colliding with the floor

Here's my system for doing this:

     [UpdateBefore(typeof(PhysicsStep))]   
     public class TogglePLinearImpulseOnFloorCollisionSystem : JobComponentSystem
     {
         EntityQuery FloorGroup;
         EntityQuery CharacterGroup;
         BuildPhysicsWorld buildPhysicsWorld;
         StepPhysicsWorld stepPhysicsWorld;
 
         protected override void OnCreate()
         {
             FloorGroup = GetEntityQuery(typeof(FloorTag));
             CharacterGroup = GetEntityQuery(typeof(ToggleInputLinearImpulseOnFloorCollisionTag));
             base.OnCreate();
             buildPhysicsWorld = World.GetOrCreateSystem<BuildPhysicsWorld>();
             stepPhysicsWorld = World.GetOrCreateSystem<StepPhysicsWorld>();
         }
         protected override JobHandle OnUpdate(JobHandle inputDeps)
         {
             var jobHandle = new TogglePLinearImpulseOnFloorCollisionJob()
             {
                 FloorGroup = GetComponentDataFromEntity<FloorTag>(true),
                 CharacterGroup = GetComponentDataFromEntity<ToggleInputLinearImpulseOnFloorCollisionTag>(true),
                 PLinearImpulseGroup = GetComponentDataFromEntity<PLinearImpulse>()
             }.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps, stepPhysicsWorld.FinalSimulationJobHandle);
             return jobHandle;
         }
     }

I get no result except for this error:

 InvalidOperationException: The previously scheduled job HavokSimulation:SyncJob reads from the Unity.Collections.NativeArray`1[Unity.Physics.MotionVelocity] SyncJob.World.DynamicsWorld.m_MotionVelocities. You are trying to schedule a new job Solver:ParallelApplyGravityAndCopyInputVelocitiesJob, which writes to the same Unity.Collections.NativeArray`1[Unity.Physics.MotionVelocity] (via ParallelApplyGravityAndCopyInputVelocitiesJob.MotionVelocities). To guarantee safety, you must include HavokSimulation:SyncJob as a dependency of the 

There is also a compiler error despite having the reference in the assembly definition:

 stepPhysicsWorld.FinalSimulationJobHandle -> Unity.Physics.IBodyPairsJobExtensions.HAVOK_PHYSICS_MISSING_FROM_ASMDEF
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Dr_SuiuS · Jan 10, 2021 at 05:55 PM

Hey guys, I found the solution.

Mistake number 1: [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))] should be used instead of [UpdateBefore(typeof(PhysicsStep))].
Mistake number 2: no need for FinalSimulationJobHandle.
Mistake number 3: A JobHandle should be completed before being returned, as it needs to finish before the next physics step. ( jobHandle.Complete() )
I'm posting the full final code of the script, as I don't want anyone else to frustrate over this:

     [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
     public class TogglePLinearImpulseOnFloorCollisionSystem : JobComponentSystem
     {
         EntityQuery FloorGroup;
         EntityQuery CharacterGroup;
         BuildPhysicsWorld buildPhysicsWorld;
         StepPhysicsWorld stepPhysicsWorld;
 
         protected override void OnCreate()
         {
             base.OnCreate();
             FloorGroup = GetEntityQuery(typeof(FloorTag));
             CharacterGroup = GetEntityQuery(typeof(ToggleInputLinearImpulseOnFloorCollisionTag));
             buildPhysicsWorld = World.GetOrCreateSystem<BuildPhysicsWorld>();
             stepPhysicsWorld = World.GetOrCreateSystem<StepPhysicsWorld>();
         }
         protected override JobHandle OnUpdate(JobHandle inputDeps)
         {
             var jobHandle = new TogglePLinearImpulseOnFloorCollisionJob()
             {
                 FloorGroup = GetComponentDataFromEntity<FloorTag>(true),
                 CharacterGroup = GetComponentDataFromEntity<ToggleInputLinearImpulseOnFloorCollisionTag>(true),
                 PLinearImpulseGroup = GetComponentDataFromEntity<PLinearImpulse>()
             }.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps);
             jobHandle.Complete();
 
             return jobHandle;
         }
     }
 
     [BurstCompile]
     struct TogglePLinearImpulseOnFloorCollisionJob : ICollisionEventsJobBase
     {
         [ReadOnly] public ComponentDataFromEntity<FloorTag> FloorGroup;
         [ReadOnly] public ComponentDataFromEntity<ToggleInputLinearImpulseOnFloorCollisionTag> CharacterGroup;
         public ComponentDataFromEntity<PLinearImpulse> PLinearImpulseGroup;
 
         public void Execute(CollisionEvent collisionEvent)
         {
             var entityA = collisionEvent.EntityA;
             var entityB = collisionEvent.EntityB;
 
             var bodyAIsCharacter = CharacterGroup.HasComponent(entityA);
             var bodyBIsCharacter = CharacterGroup.HasComponent(entityB);
 
             var bodyAIsFloor = FloorGroup.HasComponent(entityA);
             var bodyBIsFloor = FloorGroup.HasComponent(entityB);
 
             var collisionCase = 
                 (Convert.ToByte(bodyAIsFloor) << 0) + 
                 (Convert.ToByte(bodyBIsFloor) << 1) + 
                 (Convert.ToByte(bodyAIsCharacter) << 2) + 
                 (Convert.ToByte(bodyBIsCharacter) << 3);
             var pLinearImpulseComponent = new PLinearImpulse();
 
             switch (collisionCase)
             {
                 case (1 << 0) + (1 << 3):
                     pLinearImpulseComponent = PLinearImpulseGroup[entityB];
                     pLinearImpulseComponent.CanImpulse = true;
                     PLinearImpulseGroup[entityB] = pLinearImpulseComponent;
                     break;
                 case (1 << 1) + (1 << 2):
                     pLinearImpulseComponent = PLinearImpulseGroup[entityA];
                     pLinearImpulseComponent.CanImpulse = true;
                     PLinearImpulseGroup[entityA] = pLinearImpulseComponent;
                     break;
             }
         }
     }









Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

189 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I have an error "MissingReferenceException" and i dont know why 1 Answer

Migration from Unity 5.5.0f3 to Unity 2017- error and HoloLens app not building 0 Answers

Weird Error after Update 4 Answers

error CS0246: Light Color not working 0 Answers

Being Spammed With Error Messages About GiCache 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges