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();
stepPhysicsWorld = World.GetOrCreateSystem();
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var jobHandle = new TogglePLinearImpulseOnFloorCollisionJob()
{
FloorGroup = GetComponentDataFromEntity(true),
CharacterGroup = GetComponentDataFromEntity(true),
PLinearImpulseGroup = GetComponentDataFromEntity()
}.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
↧