Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug DOTS 1.0.0exp8, Incorrect Physics Behaviour in Build Vs Editor

Discussion in 'Physics for ECS' started by Karearea, Oct 2, 2022.

  1. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    I'm working on a flightsim utilising blade element theory, and have finally got the aircraft functional and working mostly as expected within the editor with 1.0.0exp8. However in builds the behaviour is completely off.

    I've checked all the components (including blobs) are baking correctly, and the systems are all operating as normal, but it's quite hard to determine exactly what fails. In plain English, the aircraft all immediately dive nose-down, and seem to have free movement from fully 90 degrees nose down, through to horizontal inverted flight, outside of that range they just resist or appear to be stalling and almost have a sort of gimbal-locked appearance. Concurrently, for some reason the drag calculations erroneously prevent them falling faster than c. 20kts.

    The character controller is a simple physics body with ApplyImpulse, and this is fine from the editor to the build. Whereas I'm doing quite a lot of GetLinearVelocity calls that get pulled through the aero system to generate lift and induced drag, before another ApplyImpulse to apply forces, and it seems to be this is where the problem lies. Is it possible there's some sort of mismatch in builds where the old translation system isn't working as expected? The bug has all the hallmarks of a local/world space error. Should I try and update to the new transform approach?

    Before I set up a bug report project, are there any caveats or known issues that might help here?

    2022.2.0b9, Entities packages all latest 1.0.0exp8 and I've updated according to the physics and general entities guides, cleared errors etc. Building to OSX Standalone with Mono. Unity Physics.
     
  2. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    I've spent a few days trying different things here, including getting and setting via the world and components

    Code (CSharp):
    1. float3 linearVelocity_ms = physicsVelocity.GetLinearVelocity(physicsMass, translation, rotation, matrix4x4.MultiplyPoint3x4(vehicleData.centreOfMass));
    2.  
    3. float3 linearVelocity_ms = world.GetLinearVelocity(vehicleData.entityRigidBody, matrix4x4.MultiplyPoint3x4(vehicleData.centreOfMass));
    4.  
    Nothing I try seems to help, so I've submitted a bug report. CASE IN-18724
    Cheers!
     
  3. JMPM-UNITY

    JMPM-UNITY

    Unity Technologies

    Joined:
    Jun 16, 2021
    Posts:
    93
    Hey, Thank you for reporting we will look at it.
     
    Karearea likes this.
  4. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Solved it!

    I was editing the aerofoils as an animation curve (lift vs angle of attack), then baking a blob with the keyframes. There's a good online resource I can import this data from to simulate real world aerofoil sections. This has worked in DOTS for the last c. 2yrs.

    For some reason the keyframes don't construct properly anymore, but I've made a similar struct and bake that instead, just constructing variable by variable with the same names like so:

    Code (CSharp):
    1. [Serializable]
    2. public struct AerofoilKey
    3. {
    4.     public float inTangent;
    5.     public float inWeight;
    6.     public float outTangent;
    7.     public float outWeight;
    8.     public float time;
    9.     public float value;
    10. }