// INTERNALS

        private void CreateBodyFixture(Physics2D.Body i_Body, Physics2D.Shape i_Shape, FP i_Friction, FP i_Restitution)
        {
            Physics2D.Fixture fixture = i_Body.CreateFixture(i_Shape);

            fixture.Friction    = i_Friction;
            fixture.Restitution = i_Restitution;
        }
예제 #2
0
        private void CreateBodyFixture(Physics2D.Body body, Physics2D.Shape shape)
        {
            Physics2D.Fixture fixture = body.CreateFixture(shape);

            if (tsMaterial != null)
            {
                fixture.Friction    = tsMaterial.friction;
                fixture.Restitution = tsMaterial.restitution;
            }
        }
예제 #3
0
        private void CreateBody(Physics2D.World world)
        {
            Physics2D.Body    body    = Physics2D.BodyFactory.CreateBody(world);
            Physics2D.Fixture fixture = body.CreateFixture(Shape);

            if (tsMaterial == null)
            {
                tsMaterial = GetComponent <TSMaterial>();
            }

            if (tsMaterial != null)
            {
                fixture.Friction    = tsMaterial.friction;
                fixture.Restitution = tsMaterial.restitution;
            }

            if (tsRigidBody == null)
            {
                body.BodyType = Physics2D.BodyType.Static;
            }
            else
            {
                if (tsRigidBody.isKinematic)
                {
                    body.BodyType = TrueSync.Physics2D.BodyType.Kinematic;
                }
                else
                {
                    body.BodyType      = Physics2D.BodyType.Dynamic;
                    body.IgnoreGravity = !tsRigidBody.useGravity;
                }

                if (tsRigidBody.mass <= 0)
                {
                    tsRigidBody.mass = 1;
                }

                body.FixedRotation = tsRigidBody.freezeZAxis;
                body.Mass          = tsRigidBody.mass;
                body.TSLinearDrag  = tsRigidBody.drag;
                body.TSAngularDrag = tsRigidBody.angularDrag;
            }

            body.IsSensor     = isTrigger;
            body.CollidesWith = Physics2D.Category.All;

            _body = body;
        }