public void FixedUpdate() { if (this.CancellationTokenSource == null) { this.Move(Vector3.zero); this.Rotate(0); } BulletSharp.Math.Matrix trans; m_collisionObject.GetWorldTransform(out trans); this.GetParent <Unit>().Position = BSExtensionMethods2.ExtractTranslationFromMatrix(ref trans); this.GetParent <Unit>().Quaternion = BSExtensionMethods2.ExtractRotationFromMatrix(ref trans); // transform.localScale = BSExtensionMethods2.ExtractScaleFromMatrix(ref trans); }
/// <summary> /// 位置更新。获取bullet的位置信息,赋值给服务端及unity /// </summary> /// <param name="m"></param> //Bullet calls this so I can copy bullet data to unity public override void SetWorldTransform(ref BM.Matrix m) { i++; if (this.i == 1) { sw = new Stopwatch(); sw.Start(); } unit.Position = BSExtensionMethods2.ExtractTranslationFromMatrix(ref m); unit.Quaternion = BSExtensionMethods2.ExtractRotationFromMatrix(ref m); if (unit.Position.y < -5000) { sw.Stop(); long xx = this.sw.ElapsedMilliseconds; } }