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

Set PhysicsVelocity.Angular multiple times canse result not determinitc?

Discussion in 'Physics for ECS' started by lijianfeng, Mar 20, 2020.

  1. lijianfeng

    lijianfeng

    Joined:
    Sep 8, 2015
    Posts:
    54
    Code (CSharp):
    1.           var forward = math.forward(rotation.Value);
    2.                                  var axis = math.cross(forward, dir);
    3.  
    4.                          //    if (math.lengthsq(physicsVelocity.Linear) == 0)
    5.                              {
    6.                                  if (math.lengthsq(axis) < 1e-6f)
    7.                                  {
    8.                                      physicsVelocity.Angular = default;
    9.  
    10.                                  }
    11.                                  else
    12.                                  {
    13.                                      axis = math.mul(math.inverse(rotation.Value), axis);
    14.                                      physicsVelocity.Angular = axis * tables.Ship[attacker.Index].attacker.lockSpeed * ConstantsOfWorld.angulerSpeedRatio;
    15.                                  }
    16.                              }
    17.                      
    18.  
    19.                              physicsVelocity.Linear = forward * tables.Ship[attacker.Index].attacker.speed * ConstantsOfWorld.moveSpeedRatio;
    If I cancle the annotation,then it become determinitc.
     
  2. lijianfeng

    lijianfeng

    Joined:
    Sep 8, 2015
    Posts:
    54
    No problem,my logic error only, I fixed it:p
     
    Adam-Mechtley and petarmHavok like this.