浏览代码

-Updated dots physics package

/dots-input
Mike Geig 5 年前
当前提交
78716fff
共有 4 个文件被更改,包括 261 次插入50 次删除
  1. 8
      Assets/Unity Physics Items/ApplyBuoyancyForceSystem.cs
  2. 10
      Assets/Unity Physics Items/DriveSystem.cs
  3. 289
      Assets/Unity Physics Items/Physics Scene.unity
  4. 4
      Packages/manifest.json

8
Assets/Unity Physics Items/ApplyBuoyancyForceSystem.cs


//var force2 = data.localArchimedesForce * subFactor;
var velocity = ComponentExtensions.GetLinearVelocity(vel2, mass, pos, rot, wp);
var velocity = ComponentExtensions.GetLinearVelocity(vel, mass, pos, rot, wp);
ComponentExtensions.ApplyImpulse(ref vel, mass, pos, rot, force * dt * mass.InverseMass, wp);
//Debug.Log(string.Format("Position: {0:f1} -- Force: {1:f2} -- Height: {2:f2}\nVelocty: {3:f2} -- Damp: {4:f2} -- Mass: {5:f1} -- K: {6:f2}", wp, force, waterLevel, velocity, localDampingForce, math.rcp(mass.InverseMass), dt));
ComponentExtensions.ApplyImpulse(ref vel, mass, pos, rot, force * dt, wp);
Debug.DrawLine(wp, force * dt + wp);
Debug.Log(string.Format("Position: {0:f1} -- Force: {1:f2} -- Height: {2:f2}\nVelocty: {3:f2} -- Damp: {4:f2} -- Mass: {5:f1} -- K: {6:f2}", wp, force, waterLevel, velocity, localDampingForce, math.rcp(mass.InverseMass), dt));
}
}

10
Assets/Unity Physics Items/DriveSystem.cs


public void Execute(Entity entity, int index, ref Translation pos, ref Rotation rot, ref PhysicsVelocity vel, ref PhysicsMass mass, ref DrivingData data)
{
Debug.Log(string.Format("Throttle: {0}, Steering {1}", throttle, steering));
if (wp.y <= -0.1f) // if the engine is deeper than 0.1
{
//if (wp.y <= -0.1f) // if the engine is deeper than 0.1
//{
//accel
throttle = Mathf.Clamp(throttle, 0f, 1f); // clamp for reasonable values
float3 forward = math.forward(rot.Value);

steering = Mathf.Clamp(steering, -1f, 1f); // clamp for reasonable values
var sTorque = new float3(0f, data.torque, -data.torque * .5f) * steering / mass.InverseInertia;
ComponentExtensions.ApplyAngularImpulse(ref vel, mass, sTorque * dt);
Debug.Log(string.Format("Force: {0}, Torque: {1} Throttle: {2}", force, sTorque, throttle));
}
//}
}
}
}

289
Assets/Unity Physics Items/Physics Scene.unity


serializedVersion: 2
m_Mass: 3200
m_Drag: 0.1
m_AngularDrag: 0.05
m_AngularDrag: 0.2
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0

m_Name:
m_EditorClassIdentifier:
_buoyancyType: 3
density: 435.7298
volume: 7.344001
voxelResolution: 0.6
density: 483.749
volume: 6.6150007
voxelResolution: 0.3
- {x: -0.90000004, y: 0.030775785, z: -1.4381936}
- {x: -0.90000004, y: 0.030775785, z: -0.8381936}
- {x: -0.3, y: 0.030775785, z: -3.2381935}
- {x: -0.3, y: 0.030775785, z: -2.6381936}
- {x: -0.3, y: 0.030775785, z: -2.0381937}
- {x: -0.3, y: 0.030775785, z: -1.4381936}
- {x: -0.3, y: 0.030775785, z: -0.8381936}
- {x: -0.3, y: 0.030775785, z: -0.23819357}
- {x: -0.3, y: 0.030775785, z: 0.36180645}
- {x: -0.3, y: 0.030775785, z: 0.96180654}
- {x: -0.3, y: 0.030775785, z: 1.5618064}
- {x: -0.3, y: 0.6307758, z: -2.6381936}
- {x: -0.3, y: 0.6307758, z: -2.0381937}
- {x: -0.3, y: 0.6307758, z: -1.4381936}
- {x: -0.3, y: 0.6307758, z: -0.8381936}
- {x: -0.3, y: 0.6307758, z: -0.23819357}
- {x: -0.3, y: 0.6307758, z: 0.36180645}
- {x: 0.3, y: 0.030775785, z: -3.2381935}
- {x: 0.3, y: 0.030775785, z: -2.6381936}
- {x: 0.3, y: 0.030775785, z: -2.0381937}
- {x: 0.3, y: 0.030775785, z: -1.4381936}
- {x: 0.3, y: 0.030775785, z: -0.8381936}
- {x: 0.3, y: 0.030775785, z: -0.23819357}
- {x: 0.3, y: 0.030775785, z: 0.36180645}
- {x: 0.3, y: 0.030775785, z: 0.96180654}
- {x: 0.3, y: 0.030775785, z: 1.5618064}
- {x: 0.3, y: 0.6307758, z: -2.6381936}
- {x: 0.3, y: 0.6307758, z: -2.0381937}
- {x: 0.3, y: 0.6307758, z: -1.4381936}
- {x: 0.3, y: 0.6307758, z: -0.8381936}
- {x: 0.3, y: 0.6307758, z: -0.23819357}
- {x: 0.3, y: 0.6307758, z: 0.36180645}
- {x: 0.90000004, y: 0.030775785, z: -1.4381936}
- {x: 0.90000004, y: 0.030775785, z: -0.8381936}
- {x: -0.9000001, y: 0.18077579, z: -2.0381937}
- {x: -0.9000001, y: 0.18077579, z: -1.7381936}
- {x: -0.9000001, y: 0.18077579, z: -1.4381937}
- {x: -0.9000001, y: 0.18077579, z: -1.1381937}
- {x: -0.9000001, y: 0.18077579, z: -0.83819366}
- {x: -0.9000001, y: 0.18077579, z: -0.5381937}
- {x: -0.9000001, y: 0.18077579, z: -0.23819366}
- {x: -0.9000001, y: 0.18077579, z: 0.06180635}
- {x: -0.6, y: -0.11922422, z: -1.4381937}
- {x: -0.6, y: -0.11922422, z: -1.1381937}
- {x: -0.6, y: -0.11922422, z: -0.83819366}
- {x: -0.6, y: -0.11922422, z: -0.5381937}
- {x: -0.6, y: -0.11922422, z: -0.23819366}
- {x: -0.6, y: -0.11922422, z: 0.06180635}
- {x: -0.6, y: 0.18077579, z: -2.9381933}
- {x: -0.6, y: 0.18077579, z: -2.6381934}
- {x: -0.6, y: 0.18077579, z: -2.3381934}
- {x: -0.6, y: 0.18077579, z: -2.0381937}
- {x: -0.6, y: 0.18077579, z: -1.7381936}
- {x: -0.6, y: 0.18077579, z: -1.4381937}
- {x: -0.6, y: 0.18077579, z: -1.1381937}
- {x: -0.6, y: 0.18077579, z: -0.83819366}
- {x: -0.6, y: 0.18077579, z: -0.5381937}
- {x: -0.6, y: 0.18077579, z: -0.23819366}
- {x: -0.6, y: 0.18077579, z: 0.06180635}
- {x: -0.6, y: 0.18077579, z: 0.3618064}
- {x: -0.6, y: 0.18077579, z: 0.66180634}
- {x: -0.6, y: 0.18077579, z: 0.9618064}
- {x: -0.6, y: 0.18077579, z: 1.2618064}
- {x: -0.6, y: 0.4807758, z: -2.6381934}
- {x: -0.6, y: 0.4807758, z: -2.3381934}
- {x: -0.6, y: 0.4807758, z: -2.0381937}
- {x: -0.6, y: 0.4807758, z: -1.7381936}
- {x: -0.6, y: 0.4807758, z: -1.4381937}
- {x: -0.6, y: 0.4807758, z: -1.1381937}
- {x: -0.6, y: 0.4807758, z: -0.83819366}
- {x: -0.6, y: 0.4807758, z: -0.5381937}
- {x: -0.6, y: 0.4807758, z: -0.23819366}
- {x: -0.6, y: 0.4807758, z: 0.06180635}
- {x: -0.6, y: 0.4807758, z: 0.3618064}
- {x: -0.6, y: 0.4807758, z: 0.66180634}
- {x: -0.30000004, y: -0.11922422, z: -2.6381934}
- {x: -0.30000004, y: -0.11922422, z: -2.3381934}
- {x: -0.30000004, y: -0.11922422, z: -2.0381937}
- {x: -0.30000004, y: -0.11922422, z: -1.7381936}
- {x: -0.30000004, y: -0.11922422, z: -1.4381937}
- {x: -0.30000004, y: -0.11922422, z: -1.1381937}
- {x: -0.30000004, y: -0.11922422, z: -0.83819366}
- {x: -0.30000004, y: -0.11922422, z: -0.5381937}
- {x: -0.30000004, y: -0.11922422, z: -0.23819366}
- {x: -0.30000004, y: -0.11922422, z: 0.06180635}
- {x: -0.30000004, y: -0.11922422, z: 0.3618064}
- {x: -0.30000004, y: -0.11922422, z: 0.66180634}
- {x: -0.30000004, y: -0.11922422, z: 0.9618064}
- {x: -0.30000004, y: 0.18077579, z: -2.9381933}
- {x: -0.30000004, y: 0.18077579, z: -2.6381934}
- {x: -0.30000004, y: 0.18077579, z: -2.3381934}
- {x: -0.30000004, y: 0.18077579, z: -2.0381937}
- {x: -0.30000004, y: 0.18077579, z: -1.7381936}
- {x: -0.30000004, y: 0.18077579, z: -1.4381937}
- {x: -0.30000004, y: 0.18077579, z: -1.1381937}
- {x: -0.30000004, y: 0.18077579, z: -0.83819366}
- {x: -0.30000004, y: 0.18077579, z: -0.5381937}
- {x: -0.30000004, y: 0.18077579, z: -0.23819366}
- {x: -0.30000004, y: 0.18077579, z: 0.06180635}
- {x: -0.30000004, y: 0.18077579, z: 0.3618064}
- {x: -0.30000004, y: 0.18077579, z: 0.66180634}
- {x: -0.30000004, y: 0.18077579, z: 0.9618064}
- {x: -0.30000004, y: 0.18077579, z: 1.2618064}
- {x: -0.30000004, y: 0.18077579, z: 1.5618063}
- {x: -0.30000004, y: 0.18077579, z: 1.8618064}
- {x: -0.30000004, y: 0.4807758, z: -2.9381933}
- {x: -0.30000004, y: 0.4807758, z: -2.6381934}
- {x: -0.30000004, y: 0.4807758, z: -2.3381934}
- {x: -0.30000004, y: 0.4807758, z: -2.0381937}
- {x: -0.30000004, y: 0.4807758, z: -1.7381936}
- {x: -0.30000004, y: 0.4807758, z: -1.4381937}
- {x: -0.30000004, y: 0.4807758, z: -1.1381937}
- {x: -0.30000004, y: 0.4807758, z: -0.83819366}
- {x: -0.30000004, y: 0.4807758, z: -0.5381937}
- {x: -0.30000004, y: 0.4807758, z: -0.23819366}
- {x: -0.30000004, y: 0.4807758, z: 0.06180635}
- {x: -0.30000004, y: 0.4807758, z: 0.3618064}
- {x: -0.30000004, y: 0.4807758, z: 0.66180634}
- {x: -0.30000004, y: 0.4807758, z: 0.9618064}
- {x: -0.30000004, y: 0.4807758, z: 1.2618064}
- {x: -0.30000004, y: 0.4807758, z: 1.5618063}
- {x: -0.30000004, y: 0.7807758, z: -2.3381934}
- {x: -0.30000004, y: 0.7807758, z: -2.0381937}
- {x: -0.30000004, y: 0.7807758, z: -1.7381936}
- {x: -0.30000004, y: 0.7807758, z: -1.4381937}
- {x: -0.30000004, y: 0.7807758, z: -1.1381937}
- {x: -0.30000004, y: 0.7807758, z: -0.83819366}
- {x: -0.000000029802322, y: -0.11922422, z: -2.9381933}
- {x: -0.000000029802322, y: -0.11922422, z: -2.6381934}
- {x: -0.000000029802322, y: -0.11922422, z: -2.3381934}
- {x: -0.000000029802322, y: -0.11922422, z: -2.0381937}
- {x: -0.000000029802322, y: -0.11922422, z: -1.7381936}
- {x: -0.000000029802322, y: -0.11922422, z: -1.4381937}
- {x: -0.000000029802322, y: -0.11922422, z: -1.1381937}
- {x: -0.000000029802322, y: -0.11922422, z: -0.83819366}
- {x: -0.000000029802322, y: -0.11922422, z: -0.5381937}
- {x: -0.000000029802322, y: -0.11922422, z: -0.23819366}
- {x: -0.000000029802322, y: -0.11922422, z: 0.06180635}
- {x: -0.000000029802322, y: -0.11922422, z: 0.3618064}
- {x: -0.000000029802322, y: -0.11922422, z: 0.66180634}
- {x: -0.000000029802322, y: -0.11922422, z: 0.9618064}
- {x: -0.000000029802322, y: -0.11922422, z: 1.2618064}
- {x: -0.000000029802322, y: 0.18077579, z: -2.9381933}
- {x: -0.000000029802322, y: 0.18077579, z: -2.6381934}
- {x: -0.000000029802322, y: 0.18077579, z: -2.3381934}
- {x: -0.000000029802322, y: 0.18077579, z: -2.0381937}
- {x: -0.000000029802322, y: 0.18077579, z: -1.7381936}
- {x: -0.000000029802322, y: 0.18077579, z: -1.4381937}
- {x: -0.000000029802322, y: 0.18077579, z: -1.1381937}
- {x: -0.000000029802322, y: 0.18077579, z: -0.83819366}
- {x: -0.000000029802322, y: 0.18077579, z: -0.5381937}
- {x: -0.000000029802322, y: 0.18077579, z: -0.23819366}
- {x: -0.000000029802322, y: 0.18077579, z: 0.06180635}
- {x: -0.000000029802322, y: 0.18077579, z: 0.3618064}
- {x: -0.000000029802322, y: 0.18077579, z: 0.66180634}
- {x: -0.000000029802322, y: 0.18077579, z: 0.9618064}
- {x: -0.000000029802322, y: 0.18077579, z: 1.2618064}
- {x: -0.000000029802322, y: 0.18077579, z: 1.5618063}
- {x: -0.000000029802322, y: 0.18077579, z: 1.8618064}
- {x: -0.000000029802322, y: 0.18077579, z: 2.1618063}
- {x: -0.000000029802322, y: 0.4807758, z: -2.9381933}
- {x: -0.000000029802322, y: 0.4807758, z: -2.6381934}
- {x: -0.000000029802322, y: 0.4807758, z: -2.3381934}
- {x: -0.000000029802322, y: 0.4807758, z: -2.0381937}
- {x: -0.000000029802322, y: 0.4807758, z: -1.7381936}
- {x: -0.000000029802322, y: 0.4807758, z: -1.4381937}
- {x: -0.000000029802322, y: 0.4807758, z: -1.1381937}
- {x: -0.000000029802322, y: 0.4807758, z: -0.83819366}
- {x: -0.000000029802322, y: 0.4807758, z: -0.5381937}
- {x: -0.000000029802322, y: 0.4807758, z: -0.23819366}
- {x: -0.000000029802322, y: 0.4807758, z: 0.06180635}
- {x: -0.000000029802322, y: 0.4807758, z: 0.3618064}
- {x: -0.000000029802322, y: 0.4807758, z: 0.66180634}
- {x: -0.000000029802322, y: 0.4807758, z: 0.9618064}
- {x: -0.000000029802322, y: 0.4807758, z: 1.2618064}
- {x: -0.000000029802322, y: 0.4807758, z: 1.5618063}
- {x: -0.000000029802322, y: 0.4807758, z: 1.8618064}
- {x: -0.000000029802322, y: 0.4807758, z: 2.1618063}
- {x: -0.000000029802322, y: 0.7807758, z: -2.3381934}
- {x: -0.000000029802322, y: 0.7807758, z: -2.0381937}
- {x: -0.000000029802322, y: 0.7807758, z: -1.7381936}
- {x: -0.000000029802322, y: 0.7807758, z: -1.4381937}
- {x: -0.000000029802322, y: 0.7807758, z: -1.1381937}
- {x: -0.000000029802322, y: 0.7807758, z: -0.83819366}
- {x: -0.000000029802322, y: 0.7807758, z: -0.5381937}
- {x: -0.000000029802322, y: 0.7807758, z: -0.23819366}
- {x: 0.29999998, y: -0.11922422, z: -2.6381934}
- {x: 0.29999998, y: -0.11922422, z: -2.3381934}
- {x: 0.29999998, y: -0.11922422, z: -2.0381937}
- {x: 0.29999998, y: -0.11922422, z: -1.7381936}
- {x: 0.29999998, y: -0.11922422, z: -1.4381937}
- {x: 0.29999998, y: -0.11922422, z: -1.1381937}
- {x: 0.29999998, y: -0.11922422, z: -0.83819366}
- {x: 0.29999998, y: -0.11922422, z: -0.5381937}
- {x: 0.29999998, y: -0.11922422, z: -0.23819366}
- {x: 0.29999998, y: -0.11922422, z: 0.06180635}
- {x: 0.29999998, y: -0.11922422, z: 0.3618064}
- {x: 0.29999998, y: -0.11922422, z: 0.66180634}
- {x: 0.29999998, y: -0.11922422, z: 0.9618064}
- {x: 0.29999998, y: 0.18077579, z: -2.9381933}
- {x: 0.29999998, y: 0.18077579, z: -2.6381934}
- {x: 0.29999998, y: 0.18077579, z: -2.3381934}
- {x: 0.29999998, y: 0.18077579, z: -2.0381937}
- {x: 0.29999998, y: 0.18077579, z: -1.7381936}
- {x: 0.29999998, y: 0.18077579, z: -1.4381937}
- {x: 0.29999998, y: 0.18077579, z: -1.1381937}
- {x: 0.29999998, y: 0.18077579, z: -0.83819366}
- {x: 0.29999998, y: 0.18077579, z: -0.5381937}
- {x: 0.29999998, y: 0.18077579, z: -0.23819366}
- {x: 0.29999998, y: 0.18077579, z: 0.06180635}
- {x: 0.29999998, y: 0.18077579, z: 0.3618064}
- {x: 0.29999998, y: 0.18077579, z: 0.66180634}
- {x: 0.29999998, y: 0.18077579, z: 0.9618064}
- {x: 0.29999998, y: 0.18077579, z: 1.2618064}
- {x: 0.29999998, y: 0.18077579, z: 1.5618063}
- {x: 0.29999998, y: 0.18077579, z: 1.8618064}
- {x: 0.29999998, y: 0.4807758, z: -2.9381933}
- {x: 0.29999998, y: 0.4807758, z: -2.6381934}
- {x: 0.29999998, y: 0.4807758, z: -2.3381934}
- {x: 0.29999998, y: 0.4807758, z: -2.0381937}
- {x: 0.29999998, y: 0.4807758, z: -1.7381936}
- {x: 0.29999998, y: 0.4807758, z: -1.4381937}
- {x: 0.29999998, y: 0.4807758, z: -1.1381937}
- {x: 0.29999998, y: 0.4807758, z: -0.83819366}
- {x: 0.29999998, y: 0.4807758, z: -0.5381937}
- {x: 0.29999998, y: 0.4807758, z: -0.23819366}
- {x: 0.29999998, y: 0.4807758, z: 0.06180635}
- {x: 0.29999998, y: 0.4807758, z: 0.3618064}
- {x: 0.29999998, y: 0.4807758, z: 0.66180634}
- {x: 0.29999998, y: 0.4807758, z: 0.9618064}
- {x: 0.29999998, y: 0.4807758, z: 1.2618064}
- {x: 0.29999998, y: 0.4807758, z: 1.5618063}
- {x: 0.29999998, y: 0.7807758, z: -2.3381934}
- {x: 0.29999998, y: 0.7807758, z: -2.0381937}
- {x: 0.29999998, y: 0.7807758, z: -1.7381936}
- {x: 0.29999998, y: 0.7807758, z: -1.4381937}
- {x: 0.29999998, y: 0.7807758, z: -1.1381937}
- {x: 0.29999998, y: 0.7807758, z: -0.83819366}
- {x: 0.6, y: -0.11922422, z: -1.4381937}
- {x: 0.6, y: -0.11922422, z: -1.1381937}
- {x: 0.6, y: -0.11922422, z: -0.83819366}
- {x: 0.6, y: -0.11922422, z: -0.5381937}
- {x: 0.6, y: -0.11922422, z: -0.23819366}
- {x: 0.6, y: -0.11922422, z: 0.06180635}
- {x: 0.6, y: 0.18077579, z: -2.9381933}
- {x: 0.6, y: 0.18077579, z: -2.6381934}
- {x: 0.6, y: 0.18077579, z: -2.3381934}
- {x: 0.6, y: 0.18077579, z: -2.0381937}
- {x: 0.6, y: 0.18077579, z: -1.7381936}
- {x: 0.6, y: 0.18077579, z: -1.4381937}
- {x: 0.6, y: 0.18077579, z: -1.1381937}
- {x: 0.6, y: 0.18077579, z: -0.83819366}
- {x: 0.6, y: 0.18077579, z: -0.5381937}
- {x: 0.6, y: 0.18077579, z: -0.23819366}
- {x: 0.6, y: 0.18077579, z: 0.06180635}
- {x: 0.6, y: 0.18077579, z: 0.3618064}
- {x: 0.6, y: 0.18077579, z: 0.66180634}
- {x: 0.6, y: 0.18077579, z: 0.9618064}
- {x: 0.6, y: 0.18077579, z: 1.2618064}
- {x: 0.6, y: 0.4807758, z: -2.6381934}
- {x: 0.6, y: 0.4807758, z: -2.3381934}
- {x: 0.6, y: 0.4807758, z: -2.0381937}
- {x: 0.6, y: 0.4807758, z: -1.7381936}
- {x: 0.6, y: 0.4807758, z: -1.4381937}
- {x: 0.6, y: 0.4807758, z: -1.1381937}
- {x: 0.6, y: 0.4807758, z: -0.83819366}
- {x: 0.6, y: 0.4807758, z: -0.5381937}
- {x: 0.6, y: 0.4807758, z: -0.23819366}
- {x: 0.6, y: 0.4807758, z: 0.06180635}
- {x: 0.6, y: 0.4807758, z: 0.3618064}
- {x: 0.6, y: 0.4807758, z: 0.66180634}
- {x: 0.9, y: 0.18077579, z: -2.0381937}
- {x: 0.9, y: 0.18077579, z: -1.7381936}
- {x: 0.9, y: 0.18077579, z: -1.4381937}
- {x: 0.9, y: 0.18077579, z: -1.1381937}
- {x: 0.9, y: 0.18077579, z: -0.83819366}
- {x: 0.9, y: 0.18077579, z: -0.5381937}
- {x: 0.9, y: 0.18077579, z: -0.23819366}
- {x: 0.9, y: 0.18077579, z: 0.06180635}
colliders:
- {fileID: 1531988075}
percentSubmerged: 0

- target: {fileID: 3457973740146875417, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}
propertyPath: m_LocalPosition.y
value: -0.389
value: 2.005
objectReference: {fileID: 0}
- target: {fileID: 3457973740146875417, guid: 0a308b87c1579fb4c9ea256406209ca5,
type: 3}

4
Packages/manifest.json


"com.unity.analytics": "3.3.2",
"com.unity.burst": "1.1.2",
"com.unity.cinemachine": "2.3.4",
"com.unity.collab-proxy": "1.2.16",
"com.unity.physics": "0.1.0-preview",
"com.unity.collab-proxy": "1.2.16",
"com.unity.physics": "0.2.0-preview",
"com.unity.purchasing": "2.0.6",
"com.unity.render-pipelines.universal": "7.0.1",
"com.unity.test-framework": "1.0.17",

正在加载...
取消
保存