ドキュメント

Unity Engine

Unity Engine

Create

Create a body using PhysicsBodyDefinition.defaultDefinition in the specified world.
読み終わるまでの所要時間 1 分最終更新 21日前

Definition

  • Type: Method
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule

Create(PhysicsWorld)

Create a body using PhysicsBodyDefinition.defaultDefinition in the specified world.
public static PhysicsBody Create(PhysicsWorld world)

Parameters

The world to create the body in.

Returns

Type

Description

PhysicsBodyThe created body.

Create(PhysicsWorld, PhysicsBodyDefinition)

Create a body in the specified world.
public static PhysicsBody Create(PhysicsWorld world, PhysicsBodyDefinition definition)

Parameters

The world to create the body in.

The body definition to use.

Returns

Type

Description

PhysicsBodyThe created body.

Examples

// 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 }); }}