I am suspecting its the apply Impulse code that is adding velocity to the rigid body. Not sure though and I am having difficulty debugging it.
[BurstCompile]
public partial struct ApplyAgentImpulseJob : IJobEntity {
public float DeltaTime;
[BurstCompile]
public void Execute(Entity _entity,
RigidBodyAspect rigidBodyAspect,
in ApplyImpulse _applyImpulseOnKeyData,
in AgentConfiguration ac) {
if (math.length(_applyImpulseOnKeyData.Direction) >
0.0f) {
if (!math.isnan(_applyImpulseOnKeyData.Direction.x) &&
!math.isnan(_applyImpulseOnKeyData.Direction.y) &&
!math.isnan(_applyImpulseOnKeyData.Direction.z)) {
Debug.Log(_applyImpulseOnKeyData.Direction);
rigidBodyAspect.ApplyLinearImpulseWorldSpace(_applyImpulseOnKeyData.Direction * DeltaTime);
}
}
if (math.length(rigidBodyAspect.LinearVelocity) > ac.Speed) {
float3 temp = rigidBodyAspect.LinearVelocity;
temp = math.normalize(temp) * ac.Speed;
rigidBodyAspect.LinearVelocity = temp;
}
}
}
Any suggestions on how to debug. Maybe i am miss understanding how physics works, or to work with the update Groups (when to trigger it).
Thank you for any pointer or ideas!!!