| Parameter | Description |
|---|---|
| world | The world to create the body in. |
PhysicsBody The created body.
Create a body using PhysicsBodyDefinition.defaultDefinition in the specified world.
| Parameter | Description |
|---|---|
| world | The world to create the body in. |
| definition | The body definition to use. |
PhysicsBody The created body.
Create a body in the specified world.
// Create a body with a body definition, then attach a circle shape to it. using UnityEngine; using Unity.U2D.Physics;
public class CreateBodyExample : MonoBehaviour { void Start() { PhysicsWorld world = PhysicsWorld.defaultWorld; PhysicsBody myObject = PhysicsBody.Create(world, new PhysicsBodyDefinition { position = new Vector2(0f, 5f) }); myObject.CreateShape(new CircleGeometry { radius = 1.5f }); } }