CreateBodyBatch
Create a batch of bodies in the world.
Read time 1 minuteLast updated 9 days ago
Definition
- Type: Method
- Namespace: UnityEngine.LowLevelPhysics2D
- Assembly: UnityEngine.Physics2DModule
CreateBodyBatch(PhysicsBodyDefinition, int, Allocator)
Create a batch of bodies in the world.
public NativeArray<PhysicsBody> CreateBodyBatch(PhysicsBodyDefinition definition, int bodyCount, Allocator allocator = Allocator.Temp)
Parameters
The body definition to use.
The number of bodies to create.
The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.
Returns
Type | Description |
|---|---|
| NativeArray<PhysicsBody> | The created bodies. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty. |
CreateBodyBatch(ReadOnlySpan<PhysicsBodyDefinition>, Allocator)
Create a batch of bodies in the world.
public NativeArray<PhysicsBody> CreateBodyBatch(ReadOnlySpan<PhysicsBodyDefinition> definitions, Allocator allocator = Allocator.Temp)
Parameters
The definitions used to create the bodies. The number of bodies produced is implicitly controlled by the number of definitions in this span.
The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.
Returns
Type | Description |
|---|---|
| NativeArray<PhysicsBody> | The created bodies. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty. |