Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. 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.