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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Set PhysicsVelocity.Angular multiple times canse result not determinitc?

Discussion in 'DOTS Physics' 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.