FarseerPhysics.Dynamics.World.removeBody C# (CSharp) Method

removeBody() public method

Destroy a rigid body. Warning: This automatically deletes all associated shapes and joints.
public removeBody ( Body body ) : void
body Body The body.
return void
		public void removeBody( Body body )
		{
			Debug.Assert( !_bodyRemoveList.Contains( body ), "The body is already marked for removal. You are removing the body more than once." );

			if( !_bodyRemoveList.Contains( body ) )
				_bodyRemoveList.Add( body );

#if USE_AWAKE_BODY_SET
            if (AwakeBodySet.Contains(body))
            {
                AwakeBodySet.Remove(body);
            }
#endif
		}

Usage Example

示例#1
0
        void decompose()
        {
            // Unsubsribe from the PostSolve delegate
            _world.contactManager.onPostSolve -= onPostSolve;

            for (int i = 0; i < parts.Count; i++)
            {
                var oldFixture = parts[i];

                var    shape    = oldFixture.shape.clone();
                object userData = oldFixture.userData;

                mainBody.destroyFixture(oldFixture);

                var body = BodyFactory.CreateBody(_world, mainBody.position, mainBody.rotation, BodyType.Dynamic, mainBody.userData);

                var newFixture = body.createFixture(shape);
                newFixture.userData = userData;
                parts[i]            = newFixture;

                body.angularVelocity = _angularVelocitiesCache[i];
                body.linearVelocity  = _velocitiesCache[i];
            }

            _world.removeBody(mainBody);
            _world.removeBreakableBody(this);
        }
All Usage Examples Of FarseerPhysics.Dynamics.World::removeBody