| name | unity-physicscore2d-world-api |
| description | Authoritative Unity 6000.5 PhysicsCore2D API reference for World & Simulation. Lists every type, property, field, method (with signatures, params, returns) for: PhysicsConstants, PhysicsCoreSettings2D, PhysicsWorld, PhysicsWorldDefinition. Use whenever working with these types in code. |
Unity PhysicsCore2D API — World & Simulation
This skill is the auto-generated API surface for the listed types. It pre-dates Claude's training data on Unity 6000.5, so it should be treated as the source of truth for member names, signatures, and documentation strings.
Generated from Unity 6000.5.0b9 UnityEngine.PhysicsCore2DModule.xml.
Top-level types in this file: PhysicsConstants, PhysicsCoreSettings2D, PhysicsWorld, PhysicsWorldDefinition.
PhysicsConstants
Contacts used by physics.
Full name: Unity.U2D.Physics.PhysicsConstants
Docs: Unity.U2D.Physics.PhysicsConstants
Fields
| Name | Summary |
|---|
MaxPolygonVertices | The maximum number of supported vertices in . |
MaxWorkers | A constant defining the maximum number of worker threads supported by physics simulation. The current device may support fewer or more than this. |
SolverGraphColorCount | The number of "colors" used for contact and joint constraints when solving the simulation. |
PhysicsCoreSettings2D
PhysicsCore Settings Asset. This contains all the global physics options along with the default values for the following definitions: - - - - - - - - - -
Full name: Unity.U2D.Physics.PhysicsCoreSettings2D
Docs: Unity.U2D.Physics.PhysicsCoreSettings2D
Properties
| Name | Summary |
|---|
alwaysDrawWorlds | Controls if worlds are always drawn independent of whether rendering is currently active or not as specified by . When true, world drawing is always active and a event is produced containing the . When false, world drawing only occurs depending on the setting. CAUTION: Drawing the world has a performance cost associated with it therefore when using this without rendering, that cost can become hidden. |
concurrentSimulations | Controls how many simulations can be started in parallel. Each one is started on its own worker and acts as its own main-thread. Workers should ideally be left free for the solver otherwise it may degrade solving performance. The actual quantity of workers used will always be capped to those available on the current device. If the total number of workers available is below 4 then parallel simulation won't occur however parallel solving using workers will. This should not be confused with the quantity of workers used when solving a simulation. See . |
contactFilterGroupMode | The mode used for the when determining if two can contact. See . |
contactFilterMode | The mode used for the when determining if two can contact. See . |
disableSimulation | Controls the simulation of any temporarily removing simulation overhead. When true, no automatic simulation will occur. When false, normal operation occurs with automatic simulation. |
lengthUnitsPerMeter | The internal length units per meter. The physics system relates all length units on meters but you may need different units for your project. You can set this value to use different units but it should only be modified before any other calls to the physics system occur and only modified once. Changing this value after any physics object has been created can result in severe simulation instabilities. Essentially there are some internal tolerances, such as how close two shapes need to be before they are considered to be touching or when two vertices of a hull are so close that they should be considered the same point. For example, internally a value of 5mm (0.005 meters) is used as a value tuned to work well with most situations with game-sized objects described in meters. If you decide to work in a different unit system (such as pixels) then 0.005 pixels is not a good value for this constant and would be too precise, leading to numerical problems, especially far from the origin. Instead you should determine roughly how many pixels you have per meter. For example, say you want 32 pixels per meter then you should set the lengthUnitsPerMeter to be 32.0f. Setting a value of (say) 32.05 would result in the 5mm being scaled up to 0.16 meters, which is a more reasonable value for determining if shapes are touching and hull vertices are too close. A good rule of thumb is to pass the pixel height of your player character to this function, so if your player character is 32 pixels high, then pass 32 to this function. Then you may confidently use pixels for all the length values sent to the physics system. All length values returned from the physics system will also then naturally be in pixels because the physics system does not do any scaling internally, however, you are now responsible for creating appropriate values for gravity, density, and forces. |
maximumWorlds | Get/Set the maximum number of worlds that can be created. The larger the number of worlds, the more memory that is initially allocated so care must be taken. Setting this value to one will reduce start-up memory usage to a minimum but will not allow any additional worlds to be created. The maximum value must be in the range of 1 to 1024. Any change will only be handled by Exiting Play mode in the Editor or restarting the player build. A single is automatically created therefore occupies one of the available worlds. |
physicsBodyDefinition | Get/Set the . |
physicsChainDefinition | Get/Set the . |
physicsDistanceJointDefinition | Get/Set the . |
physicsFixedJointDefinition | Get/Set the . |
physicsHingeJointDefinition | Get/Set the . |
physicsLayerNames | A set of 64 "layer" names associated with each bit in a when used for contacts and queries. |
physicsRelativeJointDefinition | Get/Set the . |
physicsShapeDefinition | Get/Set the . |
physicsSliderJointDefinition | Get/Set the . |
physicsWheelJointDefinition | Get/Set the . |
physicsWorldDefinition | Get/Set the . |
renderingMode | Controls drawing and rendering is allowed. NOTE: Drawing and rendering are always available in the Unity Editor however rendering requires compute buffer support on any device it is used without which no rendering will occur. See . |
transformChangeMode | Defines when changes to that has are registered with are called. NOTE: In the Unity Editor when not in Play Mode, Transform change callbacks are always and only sent at the start of the frame for authoring purposes. See . |
usePhysicsLayers | Controls if the physics 64-bit layers are used based upon or if not, the standard 32-bit layers based upon . If a asset is assigned then the physics layers ( ) will be used if is also active. If no asset is assigned then the global layers (See ) will be used. |
Methods
new()
GetAlwaysDrawWorlds()
GetConcurrentSimulations()
GetContactFilterGroupMode()
GetContactFilterMode()
GetDisableSimulation()
GetLengthUnitsPerMeter()
GetMaximumWorlds()
GetPhysicsBodyDefinition(PhysicsBodyDefinition)
GetPhysicsChainDefinition(PhysicsChainDefinition)
GetPhysicsDistanceJointDefinition(PhysicsDistanceJointDefinition)
GetPhysicsFixedJointDefinition(PhysicsFixedJointDefinition)
GetPhysicsHingeJointDefinition(PhysicsHingeJointDefinition)
GetPhysicsLayerNames(PhysicsLayers.LayerNames)
GetPhysicsRelativeJointDefinition(PhysicsRelativeJointDefinition)
GetPhysicsShapeDefinition(PhysicsShapeDefinition)
GetPhysicsSliderJointDefinition(PhysicsSliderJointDefinition)
GetPhysicsWheelJointDefinition(PhysicsWheelJointDefinition)
GetPhysicsWorldDefinition(PhysicsWorldDefinition)
GetRenderingMode()
GetTransformChangeMode()
GetUsePhysicsLayers()
PhysicsWorld
A world is a container for all other physics objects such as , , etc. A world can be simulated in isolation from all other worlds. The maximum number of worlds that can be created at one time is defined by . A world is completely isolated from all other worlds.
Full name: Unity.U2D.Physics.PhysicsWorld
Docs: Unity.U2D.Physics.PhysicsWorld
Properties
| Name | Summary |
|---|
aabbMargin | Get the distance used to expand AABBs in the broadphase dynamic tree, in meters. This allows broadphase proxies to move by a small amount without triggering a tree adjustment. This value is 0.05f * . Normally this is 5cm. |
alwaysDrawWorlds | Get if worlds are always drawn independent of whether rendering is currently active or not as specified by . When true, world drawing is always active and a event is produced containing the . When false, world drawing only occurs depending on the setting. This can be controlled via . |
autoBodyUpdateCallbacks | Controls if body update callback targets are automatically called. See |
autoContactCallbacks | Controls if shape contact callback targets are automatically called. See |
autoJointThresholdCallbacks | Controls if joint threshold callback targets are automatically called. See |
autoTriggerCallbacks | Controls if shape trigger callback targets are automatically called. See |
awakeBodyCount | Get the number of awake bodies in the world. |
bodyMaxRotation | Get the maximum rotation of a body per time step, in degrees. This limit is very large and is used to prevent numerical problems. This value is approximately 45-degrees or 0.25f * radians. |
bodyTimeToSleep | Get the time that a body must be still before it will go to sleep, in seconds. This value is 0.5 seconds. |
bodyUpdateEvents | Get the body events from the last simulation. The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced (see ). Any change to the world state can invalidate this data so referring to this data afterwards may cause an unavoidable crash! You must immediately extract what information you need and not directly reference the returned data as it will be cleared immediately after being provided. See . |
bounceThreshold | Adjust the bounce threshold, usually in meters per second. It is recommended not to make this value very small because it will prevent bodies from sleeping. |
concurrentSimulations | Gets how many simulations can be started in parallel. Whilst running simulations in parallel can improver overall performance, workers should ideally be left free for the simulation solver otherwise it may degrade solving performance. The actual quantity of workers used will always be capped to those available on the current device. If the total number of workers available is below 4 then parallel simulation won't occur as generally this would reduce overall performance, however parallel solving of each simulation using workers will still be used. This should not be confused with the quantity of workers used when solving a simulation. |
contactBeginEvents | Get the contact begin events from the last simulation. The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced (see ). The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced. Any change to the world state can invalidate this data so referring to this data afterwards may cause an unavoidable crash! You must immediately extract what information you need and not directly reference the returned data as it will be cleared immediately after being provided. See . |
contactDamping | The contact bounciness with 1 being critical damping (non-dimensional). |
contactEndEvents | Get the contact end events from the last simulation. The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced (see ). The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced. Any change to the world state can invalidate this data so referring to this data afterwards may cause an unavoidable crash! You must immediately extract what information you need and not directly reference the returned data as it will be cleared immediately after being provided. See . |
contactFilterCallbacks | Controls if contact filter callbacks will be called. A contact filter callback allows direct control over whether a contact will be created between a pair of shapes. This applies to both triggers and non-triggers but only with Dynamic bodies. These are relatively expensive so disabling them can provide a significant performance benefit. A contact filter callback will call the for both shapes involved if they implement . |
contactFilterGroupMode | Get the current value of . |
contactFilterMode | Get the current value of . |
contactFrequency | The contact stiffness, in cycles per second. |
contactHitEvents | Get the contact hit events from the last simulation. The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced (see ). Any change to the world state can invalidate this data so referring to this data afterwards may cause an unavoidable crash! You must immediately extract what information you need and not directly reference the returned data as it will be cleared immediately after being provided. See . |
contactHitEventThreshold | The contact hit event threshold controls the collision speed needed to generate a contact hit event, usually in meters per second. See . |
contactRecycleDistance | The contact recycle distance, in meters. Setting this to zero disables contact point recycling. Contact recycling reuses contact points across simulation time-steps when the relative movement is small. This feature improves stability and performance by around 25% (approximately). Contact points are not recalculated until shapes move more than 5cm (default) relative to each other. Contact recycling skips some updates such as friction, pre-solve (etc) until the contacts are no longer recycled. |
contactSpeed | The contact speed used to solve overlaps, in meters per second. |
continuousAllowed | Controls if continuous collision detection will be used between Dynamic and Static bodies. Generally you should keep continuous collision enabled to prevent fast moving objects from going through Static objects. The performance gain from disabling continuous collision is minor. |
counters | Get the world counters. |
defaultWorld | Get the default world created at start-up. This world cannot be destroyed as it is permanently owned by Unity itself. See and . |
definition | Get/Set a world definition by accessing all of its current properties. This is provided as convenience only and should not be used when performance is important as all the properties defined in the definition are accessed sequentially. You should try to only use the specific properties you need rather than using this feature. |
disableSimulation | Get if the automatic simulation of any is temporarily disabled. When true, no automatic simulation will occur. When false, normal operation occurs with automatic simulation. This can be controlled via . |
drawColors | Controls what colors are used to draw , , etc. |
drawContactType | Controls the used when drawing contact points. |
drawFillAlpha | Controls the draw fill alpha. This is used to scale the interior fill alpha and is only used when is used so that the interior color can be distinguished from the outline color by transparency. |
drawFillOptions | Controls how shape geometry is filled when drawing. See . |
drawFilter | Limits what gets drawn to a narrow selection. This only affects that are drawing all bodies, shapes etc. It does not affect selected elements or custom drawing. See . |
drawForceScale | Controls the joint contact force scale used when drawing contact forces. |
drawNormalScale | Controls the joint contact normal scale used when drawing contact normals. |
drawOptions | Limits what gets drawn to a broad selection. See . |
drawPointScale | Controls the draw point scale used when drawing points. |
drawThickness | Controls the draw thickness (outline and orientation). |
elementDepth | Controls the element depth. When using custom drawing of geometry or primitive shapes there is no reference to the orthogonal axis used with respect to the current . The element depth is in world-space and for each transform plan is defined as: - Element depth is rendered along the Z axis when using . - Element depth is rendered along the Y axis when using . - Element depth is rendered along the X axis when using . You should set the element depth before performing any custom draw. The element depth will be reset to zero when rendering is complete. |
globalCounters | Get the world counters, summed for all the active worlds. |
globalProfile | Get the world timing profile, summed for all the active worlds. |
gravity | Get/Set the gravity vector applied to all bodies in the world, usually in m/s^2. |
hugeWorldExtent | Gets what physics considers a large extent in the world. Positions greater than approximately 16km will have precision problems, so 100km as a limit should be fine in all cases. This is used to detect bad values. This value is 100000.0f * . |
isDefaultWorld | Check if this is the default . The default world is automatically created at start-up. |
isEmpty | Check if the world is empty as defined by having no bodies, shapes or joints. |
isOwned | Get if the world is owned. See . |
isRenderingAllowed | Get if rendering is currently allowed. Rendering is always allowed in the Editor however it is only allowed elsewhere depending on . |
isValid | Check if the world is valid. |
jointThresholdEvents | Get the joint events from the last simulation. An event is produced by a Joint which exceeds either its or . The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced (see ). Any change to the world state can invalidate this data so referring to this data afterwards may cause an unavoidable crash! You must immediately extract what information you need and not directly reference the returned data as it will be cleared immediately after being provided. See . |
lastSimulationDeltaTime | Get the delta-time used for the last simulation run. |
lastSimulationTimestamp | Get the timestamp when the last simulation was run. |
lengthUnitsPerMeter | Get the internal length units per meter. Changes won't take effect until exiting play mode. The physics system relates all length units on meters but you may need different units for your project. You can set this value to use different units but it should only be modified before any other calls to the physics system occur and only modified once. Changing this value after any physics object has been created can result in severe simulation instabilities. For example, if your game uses pixels for units you can use pixels for all length values sent to the physics system. There should be no extra cost however, the physics system has some internal tolerances and thresholds that have been tuned for meters. By calling this function, the physics system is better able to adjust those tolerances and thresholds to improve accuracy. A good rule of thumb is to pass the height of your player character to this function. So if your player character is 32 pixels high, then pass 32 to this function. Then you may confidently use pixels for all the length values sent to the physics system. All length values returned from the physics system will also then be in pixels because the physics system does not do any scaling internally, however, you are now on the hook for coming up with good values for gravity, density, and forces. The default value is 1. |
linearSlop | Get the small length used as a collision and constraint tolerance, in meters. Usually it is chosen to be numerically significant, but visually insignificant. This value is 0.005f * . Normally this is 0.5cm. |
maximumLinearSpeed | Get/Set the maximum linear speed. |
maximumWorldsAllocated | Get the actual allocated maximum worlds available. This can differ at runtime from if it was changed and the physics system has not been restarted. Another reason this can differ would be if there was not available memory to allocate the requested maximum worlds. |
ownerUserData | Get that can be used for any purpose, typically by the owner only. |
paused | Get/Set if the world is paused. When paused, any simulation attempted will be ignored whether it be automatic or manual. |
preSolveCallbacks | Controls if pre-solve callbacks will be called. This only applies to Dynamic bodies and is ignored for triggers. These are relatively expensive so disabling them can provide a significant performance benefit. A pre-solve callback will call the for both shapes involved if they implement . |
profile | Get the world timing profile. |
renderingMode | Get the current value of . NOTE: Drawing and rendering are always available in the Unity Editor however rendering requires compute buffer support on any device it is used without which no rendering will occur. |
safetyLocksEnabled | Get/Set whether safety threading locks are enabled or not. Locks are enabled by default however on platforms that do not support threading, locks are not used. Disabling locks can result in a small performance boost however, please note the following EXTREME CAUTIONS. Typically, per-world, multiple read operations can happen in parallel however only a single write operation can occur concurrently. Read and write operations can never happen at the same time. Locking is a self-balancing reader-preferred system that tries to reduce writers "starving". Once a writer is in a queue, it registers incoming readers as waiting readers and, once active readers are handled, it starts processing a single writer. After that writer has been handled, it flips waiting readers into active readers and processes them. Whilst this system is extremely fast, it does have a very small overhead. Disabling this system can give a small performance boost but is nearly always not worth it therefore this option should be used for testing only. EXTREME CAUTION should be taken if disabling locks on platforms that support threading! A majority of this API is thread-safe and is is due to the safety locks! Locks are used to ensure that read and write operations do not interfere with each other. Locks also ensure that no read or write operations happen during a simulation step. Overlapping read or write operations will almost certainly result in corruptions and a subsequent crash, so unless you are absolutely sure this is not the case, do not disable locks! |
simulationSubSteps | Get/Set the simulation sub-steps to use during simulation. See . |
simulationType | Get/Set the simulation type which controls when or if the simulation will be automatically simulated. See . |
simulationWorkers | Get/Set the simulation worker count for the world. A single simulation worker is always used for simulation therefore a worker count of one means single thread simulation only. The actual quantity of workers used will always be capped to those available on the current device and reading the property will return the number of workers actually being used by the device. Changing the worker count continuously is not recommend and will impact performance as it requires the task queue be recreated. See . |
sleepingAllowed | Controls if bodies go to sleep when not moving and not interacting. Sleeping can provide a significant performance improvement when many Dynamic or Kinematic bodies are in the world. |
speculativeContactDistance | Get the distance at which speculative contacts will be calculated. This reduces jitter. This value is 4.0f * . Normally this is 2cm. |
syncInterpolation | Controls if an extra write pass prior to the script fixed-update callback is made for any interpolation tweens to ensure that transforms are synchronized to the final body pose. Because this is an extra write pass, it has an impact on overall performance so only enable if you require transforms synchronized this way. NOTE: This only affects that have their set to . |
transformChangeMode | Get the current value of . See . |
transformPlane | Controls the transform plane that the world uses when writing transforms. See . |
transformPlaneCustom | Controls the transformation for the to allow transformation writing and reading to/from a custom 2D plane. See . |
transformTweenMode | Controls if and how Transform tweens are calculated and/or written. Transform tweening is where bodies that have their set, write to the each frame depending on the specific body set. Regardless of this setting, Transform tweening is never used if the is or is . |
transformWriteCallbackTarget | Get/Set the custom that implements the to which and will be sent. The callback will only occur if is set to and there are available. The object assigned here will be kept alive, not allowing the GC to dispose of it. To remove the object assigned here, set the callback target to NULL. |
transformWriteMode | Controls how transform writing is handled. Only bodies that have their active and produce a will write to a transform. See . |
triggerBeginEvents | Get the trigger begin events from the last simulation. The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced (see ). Any change to the world state can invalidate this data so referring to this data afterwards may cause an unavoidable crash! You must immediately extract what information you need and not directly reference the returned data as it will be cleared immediately after being provided. See . |
triggerEndEvents | Get the trigger end events from the last simulation. The objects returned should be checked to see if they are valid before accessing as they may have been deleted since this event was produced (see ). Any change to the world state can invalidate this data so referring to this data afterwards may cause an unavoidable crash! You must immediately extract what information you need and not directly reference the returned data as it will be cleared immediately after being provided. See . |
usePhysicsLayers | Get if the option of is active or not. If no asset is assigned, this option will return false (inactive). When active, the physics 64-bit layers are used (see ) for property drawers and . When inactive, the 32-bit layers are used (see ) for property drawers and . In all cases, the physics system itself will always use the full 64-bit layers assigned, however when using 32-bit layers, the top 32-bits will be set to zero. |
userData | Get/Set that can be used for any purpose. This cannot be set on the and will always be at the default. The physics system doesn't use this data, it is entirely for custom use. |
warmStartingAllowed | Is warm-starting allowed in the world? Disabling warming-starting will severely impact stability. This is typically used for testing only! |
worldCount | Get the number of created worlds. This will be a value in the range of 1 to . |
Methods
CastGeometry(CircleGeometry, Vector2, PhysicsQuery.QueryFilter, PhysicsQuery.WorldCastMode, Unity.Collections.Allocator)
Returns the shape(s) that intersect the specified Circle geometry as it is cast through the world. See , , and
Params:
geometry — The Circle geometry used to cast through the world. This must be in world-space.
translation — The translation relative to the geometry defining the direction the geometry will move through the world.
filter — The filter to control what results are returned.
castMode — Controls how many and in what order the results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query cast results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
CastGeometry(CapsuleGeometry, Vector2, PhysicsQuery.QueryFilter, PhysicsQuery.WorldCastMode, Unity.Collections.Allocator)
Returns the shape(s) that intersect the specified Capsule geometry as it is cast through the world. See , , and .
Params:
geometry — The Capsule geometry used to cast through the world. This must be in world-space.
translation — The translation relative to the geometry defining the direction the geometry will move through the world.
filter — The filter to control what results are returned.
castMode — Controls how many and in what order the results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query cast results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
CastGeometry(PolygonGeometry, Vector2, PhysicsQuery.QueryFilter, PhysicsQuery.WorldCastMode, Unity.Collections.Allocator)
Returns the shape(s) that intersect the specified Polygon geometry as it is cast through the world. See , , and .
Params:
geometry — The Polygon geometry used to cast through the world. This must be in world-space.
translation — The translation relative to the geometry defining the direction the geometry will move through the world.
filter — The filter to control what results are returned.
castMode — Controls how many and in what order the results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query cast results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
CastMover(PhysicsQuery.WorldMoverInput)
Cast a "Mover" which is geometry designed to collide with the world and solve its movement. Everything is specified via the with results returned in .
Params:
input — The configuration of the mover to cast.
Returns: The solved mover results.
CastRay(PhysicsQuery.CastRayInput, PhysicsQuery.QueryFilter, PhysicsQuery.WorldCastMode, Unity.Collections.Allocator)
Returns the shape(s) that intersect the specified Ray. Technically this is a line-segment and not an infinite ray. See , , and .
Params:
input — The configuration of the ray to cast.
filter — The filter to control what results are returned.
castMode — Controls how many and in what order the results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query cast results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
CastShape(PhysicsShape, Vector2, PhysicsQuery.QueryFilter, PhysicsQuery.WorldCastMode, Unity.Collections.Allocator)
Returns the shape(s) that intersect the specified shape as it is cast through the world. The selected shape is excluded from any results and must be in this world otherwise a warning will be produced. Neither or shape types are supported. See , , and .
Params:
shape — The shape used to cast through the world.
translation — The translation relative to the shape pose defining the direction the shape geometry will move through the world.
filter — The filter to control what results are returned.
castMode — Controls how many and in what order the results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query cast results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
CastShapeProxy(PhysicsShape.ShapeProxy, Vector2, PhysicsQuery.QueryFilter, PhysicsQuery.WorldCastMode, Unity.Collections.Allocator)
Returns the shape(s) that intersect the specified Circle geometry as it is cast through the world. See , , and .
Params:
shapeProxy — The shape proxy to use. This must be in world-space.
translation — The translation relative to the shape proxy defining the direction the shape proxy will move through the world.
filter — The filter to control what results are returned.
castMode — Controls how many and in what order the results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query cast results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
CheckTransformChanges()
Checks for any transform changes. Anything using will immediately be notified of any changes. This should be used sparingly otherwise it may impact performance. The preference should be not using this but instead control transform changes to be monitored with .
Returns: The number of changed transforms that were detected.
ClearDraw()
Clear all the custom drawn items.
ClearTransformWriteTweens()
Clear all the existing Transform Write Tweens. See and .
Create()
Create a PhysicsWorld using the .
Returns: The created world.
Create(PhysicsWorldDefinition)
Create a PhysicsWorld.
Params:
definition — The world definition to use.
Returns: The created world.
CreateBody()
Create a body using the in the world. See .
Returns: The created body.
CreateBody(PhysicsBodyDefinition)
Create a body in the world. See .
Params:
definition — The body definition to use.
Returns: The created body.
CreateBodyBatch(PhysicsBodyDefinition, int, Unity.Collections.Allocator)
Create a batch of bodies in the world.
Params:
definition — The body definition to use.
bodyCount — The number of bodies to create.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: 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{Unity.U2D.Physics.PhysicsBodyDefinition}, Unity.Collections.Allocator)
Create a batch of bodies in the world.
Params:
definitions — The definitions used to create the bodies. The number of bodies produced is implicitly controlled by the number of definitions in this span.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: 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.
CreateJoint(PhysicsDistanceJointDefinition)
Create a PhysicsDistanceJoint in the world. See .
Params:
definition — The joint definition to use.
Returns: The created joint.
CreateJoint(PhysicsRelativeJointDefinition)
Create a PhysicsRelativeJoint in the world. See .
Params:
definition — The joint definition to use.
Returns: The created joint.
CreateJoint(PhysicsIgnoreJointDefinition)
Create an PhysicsIgnoreJoint in the world. See .
Params:
definition — The joint definition to use.
Returns: The created joint.
CreateJoint(PhysicsSliderJointDefinition)
Create a PhysicsSliderJoint in the world. See .
Params:
definition — The joint definition to use.
Returns: The created joint.
CreateJoint(PhysicsHingeJointDefinition)
Create a PhysicsHingeJoint in the world. See .
Params:
definition — The joint definition to use.
Returns: The created joint.
CreateJoint(PhysicsFixedJointDefinition)
Create a PhysicsFixedJoint in the world. See .
Params:
definition — The joint definition to use.
Returns: The created joint.
CreateJoint(PhysicsWheelJointDefinition)
Create a PhysicsWheelJoint in the world. See .
Params:
definition — The joint definition to use.
Returns: The created joint.
CreateOwnerKey(Object)
Create an owner key.
Params:
owner — The object that owns this key. Whilst it is valid to not specify an owner object (NULL), it is recommended as the owner key can use the hash-code of the object to generate a more unique key.
Returns: The new owner key.
Destroy(int)
Destroy a world, destroying all objects contained within it such as all and attached and . If the object is owned with then you must provide the owner key it returned. Failing to do so will return a warning and the world will not be destroyed. You cannot destroy the as it is permanently owned by Unity itself.
Params:
ownerKey — Optional owner key returned when using .
Returns: If the world was destroyed or not.
DestroyBodyBatch(ReadOnlySpan{Unity.U2D.Physics.PhysicsBody})
Destroy a batch of bodies. Any invalid bodies will be ignored. Owned bodies will produce a warning and will not be destroyed (See ).
Params:
bodies — The bodies to destroy.
DestroyJointBatch(ReadOnlySpan{Unity.U2D.Physics.PhysicsJoint})
Destroy a batch of joints. Any invalid joints will be ignored. Owned joints will produce a warning and will not be destroyed ( ).
Params:
joints — The joints to destroy.
DestroyShapeBatch(ReadOnlySpan{Unity.U2D.Physics.PhysicsShape}, bool)
Destroy a batch of shapes, destroying all the shapes are involved in. Any invalid shapes will be ignored including chain segment shapes created via a (the chain must be destroyed)." Owned shapes will produce a warning and will not be destroyed ( ). See .
Params:
shapes — The shapes to destroy.
updateBodyMass — Whether to update the body mass configuration. Not doing so is faster, especially when destroying multiple shapes.
DrawAABB(PhysicsAABB, Color, float, PhysicsWorld.DrawFillOptions)
Draw an AABB.
Params:
aabb — The AABB to draw.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawAllWorlds(PhysicsAABB)
DrawBox(PhysicsTransform, Vector2, float, Color, float, PhysicsWorld.DrawFillOptions)
Draw a Box.
Params:
transform — The transform to use on the specified points.
size — The size of the box.
radius — The radius of the box.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawCapsule(PhysicsTransform, Vector2, Vector2, float, Color, float, PhysicsWorld.DrawFillOptions)
Draw a Capsule outline. For further information on the parameters, see .
Params:
transform — The transform to use on the specified centers.
center1 — The local center of the first semi-circle.
center2 — The local center of the second semi-circle.
radius — The radius of the capsule.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawCircle(Vector2, float, Color, float, PhysicsWorld.DrawFillOptions)
Draw a Circle outline. For further information on the parameters, see .
Params:
center — The center of the circle in PhysicsWorld space.
radius — The radius of the circle.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawGeometry(CircleGeometry, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw the specified Circle Geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with. Here, the color alpha is used only for the interior fill color but will never be completely opaque.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawGeometry(ReadOnlySpan{Unity.U2D.Physics.CircleGeometry}, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw the specified span of Circle Geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with. Here, the color alpha is used only for the interior fill color but will never be completely opaque.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawGeometry(CapsuleGeometry, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw the specified Capsule geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with. Here, the color alpha is used only for the interior fill color but will never be completely opaque.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawGeometry(ReadOnlySpan{Unity.U2D.Physics.CapsuleGeometry}, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw the specified span of Capsule geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with. Here, the color alpha is used only for the interior fill color but will never be completely opaque.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawGeometry(PolygonGeometry, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw the specified Polygon geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with. Here, the color alpha is used only for the interior fill color but will never be completely opaque.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawGeometry(ReadOnlySpan{Unity.U2D.Physics.PolygonGeometry}, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw the specified span of Polygon geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with. Here, the color alpha is used only for the interior fill color but will never be completely opaque.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawGeometry(SegmentGeometry, PhysicsTransform, Color, float)
Draw the specified Segment geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
DrawGeometry(ReadOnlySpan{Unity.U2D.Physics.SegmentGeometry}, PhysicsTransform, Color, float)
Draw the specified span of Segment geometry.
Params:
geometry — The geometry to draw.
transform — The transform to use on the specified geometry.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
DrawLine(Vector2, Vector2, Color, float)
Draw a Line.
Params:
point0 — The start of the line.
point1 — The end of the line.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
DrawLineStrip(PhysicsTransform, ReadOnlySpan{UnityEngine.Vector2}, bool, Color, float)
Draw a set of vertices as lines joined to each other.
Params:
transform — The transform to use on the specified vertices.
vertices — The vertices defining the lines. A minimum of two vertices must be present.
loop — Should the first and last vertices be joined by a line?
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
DrawPoint(Vector2, float, Color, float)
Draw a Point. A Point is similar to a filled Circle except the radius here is specified in pixels rather than world units.
Params:
position — The position of the point in PhysicsWorld space.
radius — The radius of the point, in pixels (approximately).
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
DrawQueryCastGeometry(CircleGeometry, Vector2, Color, float, PhysicsWorld.DrawFillOptions, bool)
Draw the query input.
Params:
geometry — The Circle geometry used to cast through the world. This must be in world-space.
translation — The translation relative to the geometry defining the direction the geometry will move through the world.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
drawEnd — Whether to draw the geometry at the end of the translation or not.
DrawQueryCastGeometry(CapsuleGeometry, Vector2, Color, float, PhysicsWorld.DrawFillOptions, bool)
Draw the query input.
Params:
geometry — The Circle geometry used to cast through the world. This must be in world-space.
translation — The translation relative to the geometry defining the direction the geometry will move through the world.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
drawEnd — Whether to draw the geometry at the end of the translation or not.
DrawQueryCastGeometry(PolygonGeometry, Vector2, Color, float, PhysicsWorld.DrawFillOptions, bool)
Draw the query input.
Params:
geometry — The Circle geometry used to cast through the world. This must be in world-space.
translation — The translation relative to the geometry defining the direction the geometry will move through the world.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
drawEnd — Whether to draw the geometry at the end of the translation or not.
DrawQueryCastRay(PhysicsQuery.CastRayInput, Color, float, bool)
Draw the query input.
Params:
input — The query input to draw.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawEnd — Whether to draw the arrow at the end of the translation or not.
DrawQueryCastRay(ReadOnlySpan{Unity.U2D.Physics.PhysicsQuery.CastRayInput}, Color, float, bool)
Draw the query inputs.
Params:
inputs — The query inputs to draw.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawEnd — Whether to draw the arrow at the end of the translation or not.
DrawQueryCastShape(PhysicsShape, Vector2, Color, float, PhysicsWorld.DrawFillOptions, bool)
Draw the query input.
Params:
shape — The shape used to cast through the world.
translation — The translation relative to the shape pose defining the direction the geometry will move through the world.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
drawEnd — Whether to draw the shape at the end of the translation or not.
DrawQueryCastShapeProxy(PhysicsShape.ShapeProxy, Vector2, Color, float, PhysicsWorld.DrawFillOptions, bool)
Draw the query input.
Params:
shapeProxy — The shape proxy to use. This must be in world-space.
translation — The translation relative to the shape proxy defining the direction the shape proxy will move through the world.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
drawEnd — Whether to draw the shape proxy at the end of the translation or not.
DrawQueryResult(PhysicsQuery.CastResult, Color, float, bool, bool)
Draw the returned from multiple queries. Only a result where is true is drawn.
Params:
result — The result to use.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawPoint — Whether to draw the point in the result or not.
drawNormal — Whether to draw the normal in the result or not.
DrawQueryResult(ReadOnlySpan{Unity.U2D.Physics.PhysicsQuery.CastResult}, Color, float, bool, bool)
Draw the returned from multiple queries. Only a result where is true is drawn.
Params:
results — The results to use.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawPoint — Whether to draw the point in the result or not.
drawNormal — Whether to draw the normal in the result or not.
DrawQueryResult(PhysicsQuery.WorldCastResult, Color, float, bool, bool)
Draw the returned from multiple queries.
Params:
result — The result to use.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawPoint — Whether to draw the point in the result or not.
drawNormal — Whether to draw the normal in the result or not.
DrawQueryResult(ReadOnlySpan{Unity.U2D.Physics.PhysicsQuery.WorldCastResult}, Color, float, bool, bool)
Draw the returned from multiple queries.
Params:
results — The results to use.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawPoint — Whether to draw the point in the result or not.
drawNormal — Whether to draw the normal in the result or not.
DrawShapeProxy(PhysicsShape.ShapeProxy, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw a .
Params:
shapeProxy — The ShapeProxy to draw.
transform — The transform to use on the specified points.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawShapeProxy(ReadOnlySpan{Unity.U2D.Physics.PhysicsShape.ShapeProxy}, PhysicsTransform, Color, float, PhysicsWorld.DrawFillOptions)
Draw the specified span of .
Params:
shapeProxies — The ShapeProxies to draw.
transform — The transform to use on the specified points.
color — The color to draw with.
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
drawFillOptions — Controls what aspects of the primitive is drawn.
DrawTransformAxis(PhysicsTransform, float, float)
Draw a Transform axis.
Params:
transform — The Transform axis to draw.
scale — —
lifetime — How long the element should be drawn for, in seconds. The default is zero indicating that it should only be drawn once. Lifetime is only used when the world is playing.
Equals(object)
Equals(PhysicsWorld)
Explode(PhysicsWorld.ExplosionDefinition)
Apply a radial explosion applying impulses away from the position to all bodies found within in the radius.
Params:
definition — The explosion definition describing how the explosion should be handled.
GetBodies(Unity.Collections.Allocator)
Get all the active in the specified world.
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The active body results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
GetBodyUpdateCallbackTargets(Unity.Collections.Allocator)
Get all current where either of the involved are valid (see ) and have a callback target assigned (see ).
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The contact callback target results. This must be disposed of after use otherwise leaks will occur. The exception to this is if there are no targets returned.
GetBodyUpdateOwnerUserData(Unity.Collections.Allocator)
Get all assigned to each returned with . The Native Array returned will be of the same length and be ordered the same as the returned with . Any that are not valid will return a default .
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: A Native Array containing all for each returned with .
GetBodyUpdateUserData(Unity.Collections.Allocator)
Get all assigned to each returned with . The Native Array returned will be of the same length and be ordered the same as the returned with . Any that are not valid will return a default .
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: A Native Array containing all for each returned with .
GetContactCallbackTargets(Unity.Collections.Allocator)
Get all current and where either of the involved are valid (see ) and have a callback target assigned (see ).
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The contact callback target results. This must be disposed of after use otherwise leaks will occur. The exception to this is if there are no targets returned.
GetHashCode()
GetJoints(Unity.Collections.Allocator)
Get all the active in the specified world.
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The active joints results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
GetJointThresholdCallbackTargets(Unity.Collections.Allocator)
Get all current where either of the involved are valid (see ) and have a callback target assigned (see ).
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The joint callback target results. This must be disposed of after use otherwise leaks will occur. The exception to this is if there are no targets returned.
GetOwner()
Get the owner object associated with this world as specified using .
Returns: The owner object associated with this world or NULL if no owner has been specified.
GetTransformWriteTweens()
Gets all the existing Transform Write Tweens that are handled per-frame. If the is then the tweens are sorted into ascending transform depth allowing writing to the Transform hierarchy by simply iterating the tweens . If the is then the tweens are unsorted as a is used to write them. See and .
Returns: All the existing Transform Write Tweens that are handled per-frame.
GetTriggerCallbackTargets(Unity.Collections.Allocator)
Get all current and where either of the involved are valid (see ) and have a callback target assigned (see ).
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The trigger callback target results. This must be disposed of after use otherwise leaks will occur. The exception to this is if there are no targets returned.
GetWorlds(Unity.Collections.Allocator)
Get all the active . This includes the so will always contain at least a single world.
Params:
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The active world results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
operator ==(PhysicsWorld, PhysicsWorld)
operator !=(PhysicsWorld, PhysicsWorld)
OverlapAABB(PhysicsAABB, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that potentially overlap the provided AABB. The overlap is between AABB of shapes in the world therefore it may not result in an exact overlap of the shape itself. See , , and .
Params:
aabb — The AABB used to check overlap. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapAABB(ReadOnlySpan{Unity.U2D.Physics.PhysicsAABB}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that potentially overlap the provided AABBs. The overlap is between AABB of shapes in the world therefore it may not result in an exact overlap of the shape itself. See , , and .
Params:
aabbs — The AABBs used to check overlap. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(CircleGeometry, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Circle geometry. A circle with a radius of zero is equivalent to . See , , and
Params:
geometry — The Circle geometry used to check overlap. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(ReadOnlySpan{Unity.U2D.Physics.CircleGeometry}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Circle geometry. A circle with a radius of zero is equivalent to . See , , and
Params:
geometry — The Circle geometry used to check overlap. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(CapsuleGeometry, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Capsule geometry. See , , and .
Params:
geometry — The Capsule geometry used to check overlap. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(ReadOnlySpan{Unity.U2D.Physics.CapsuleGeometry}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Capsule geometry. See , , and .
Params:
geometry — The Capsule geometry used to check overlap. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(PolygonGeometry, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Polygon geometry. See , , and .
Params:
geometry — The Polygon geometry used to check overlap. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(ReadOnlySpan{Unity.U2D.Physics.PolygonGeometry}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Polygon geometry. See , , and .
Params:
geometry — The Polygon geometry used to check overlap. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(SegmentGeometry, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Segment geometry. See , , and .
Params:
geometry — The Segment geometry used to check overlap. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(ReadOnlySpan{Unity.U2D.Physics.SegmentGeometry}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Segment geometry. See , , and .
Params:
geometry — The Segment geometry used to check overlap. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(ChainSegmentGeometry, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Chain-Segment geometry. See , , and .
Params:
geometry — The Chain-Segment geometry used to check overlap. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapGeometry(ReadOnlySpan{Unity.U2D.Physics.ChainSegmentGeometry}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided Chain-Segment geometry. See , , and .
Params:
geometry — The Chain-Segment geometry used to check overlap. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapPoint(Vector2, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided point. This first converts the shape to a and uses . See , and .
Params:
point — The point used to check overlap. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapPoint(ReadOnlySpan{UnityEngine.Vector2}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided point(s). This first converts the shape to a and uses . See , and .
Params:
points — The points used to check overlap. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapShape(PhysicsShape, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the provided shape. The selected shape is excluded from any results and must be in this world otherwise a warning will be produced.
Params:
shape — The shape used to check overlap.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapShapeProxy(PhysicsShape.ShapeProxy, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the shape proxy. See . and .
Params:
shapeProxy — The shape proxy to use. This must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
OverlapShapeProxy(ReadOnlySpan{Unity.U2D.Physics.PhysicsShape.ShapeProxy}, PhysicsQuery.QueryFilter, Unity.Collections.Allocator)
Returns all shapes that overlap the shape proxies. See . and .
Params:
shapeProxies — The shape proxies to use. These must be in world-space.
filter — The filter to control what results are returned.
allocator — The memory allocator to use for the results. This can only be , or .
Returns: The query overlap results. This NativeArray must be disposed of after use otherwise leaks will occur. The exception to this is if the array is empty.
RegisterTransformChange(Transform, PhysicsCallbacks.ITransformChangedCallback)
Register a transform watcher to call the specified callback when a transform changes. See for the types of transform changes that are watched for. You MUST unregister this when no longer needed with otherwise you will receive warnings.
Params:
transform — The transform to watch for changes.
callback — The callback to perform when a transform change is detected.
Reset()
Reset the world to a canonical state so that it will reproduce identical results each time. The world must be empty for this to be called otherwise a warning is produced.
SendAllCallbacks()
Send all callbacks to targets: - - - -
SendBodyUpdateCallbacks()
Send all current where the involved are valid (see ) and have a callback target assigned (see ). Only callback targets that implement will be called. This will be called automatically if is true. This must be called on the main thread.
SendContactCallbacks()
Send all current and where either of the involved are valid (see ) and have a callback target assigned (see ). These events will only be created if both of the shape pairs has set to true. Only callback targets that implement will be called. This will be called automatically if is true. This must be called on the main thread.
SendJointThresholdCallbacks()
Send all current where the involved are valid (see ) and have a callback target assigned (see ). These events will only be created if the joint exceeds its or . Only callback targets that implement will be called. This will be called automatically if is true. This must be called on the main thread.
SendTriggerCallbacks()
Send all current and where either of the involved are valid (see ) and have a callback target assigned (see ). These events will only be created if one of the shape pairs has set to true. Only callback targets that implement will be called. This will be called automatically if is true. This must be called on the main thread.
SetElementDepth3D(Vector3)
Set the element depth using the specified 3D position. The relevant axis will be extracted using the current . If is used, the element depth is always set to zero. For more details, see .
Params:
position — The 3D position to extract the element depth from.
SetOwner(ReadOnlySpan{Unity.U2D.Physics.PhysicsWorld}, Object, int)
Set the owner object using the specified owner key. You can only set the owner once, multiple attempts will produce a warning. This call does not bind the lifetime of the specified owner object, it is simply a reference. Whilst it is valid to not specify an owner object (NULL), it is recommended for debugging purposes.
Params:
worlds — The worlds to set ownership for.
owner — The object that owns this key. Whilst it is valid to not specify an owner object (NULL), it is recommended for debugging purposes.
ownerKey — The owner key to be used. The value must be non-zero. You can use for this value although any non-zero integer will work.
SetOwner(Object, int)
Set the owner object using the specified owner key. You can only set the owner once, multiple attempts will produce a warning. This call does not bind the lifetime of the specified owner object, it is simply a reference. It is also valid to not specify an owner object (NULL) to simply gain an owner key however it can be useful, if simply for debugging purposes and discovery, to know which object is the owner.
Params:
owner — The object that owns this key. This can be NULL if not required but is recommended as the key is formed in part by the hash-code of the owner object.
ownerKey — The owner key to be used. If zero then a new owner key is created. You can use for this value although any non-zero integer will work.
SetOwner(Object)
Set the owner object using the specified owner key. You can only set the owner once, multiple attempts will produce a warning. This call does not bind the lifetime of the specified owner object, it is simply a reference. It is also valid to not specify an owner object (NULL) to simply gain an owner key however it can be useful, if simply for debugging purposes and discovery, to know which object is the owner.
Params:
owner — The object that owns this key. This can be NULL if not required but is recommended as the key is formed in part by the hash-code of the owner object.
Returns: The owner key assigned.
SetOwnerUserData(PhysicsUserData, int)
Set that can be used for any purpose, typically by the owner only.
Params:
physicsUserData — The user data to set.
ownerKey — Optional owner key returned when using .
SetTransform(Transform, Vector3, bool)
Set the position without causing a to be generated by default. See .
Params:
transform — The transform to change.
position — The global position to set the transform to.
transformChangedEvent — By default, no transform changed event will be produced however this behaviour can be overridden with this argument.
SetTransform(Transform, Vector3, Quaternion, bool)
Set the position and rotation without causing a to be generated. See .
Params:
transform — The transform to change.
position — The global position to set the transform to.
rotation — The global rotation to set the transform to.
transformChangedEvent — By default, no transform changed event will be produced however this behaviour can be overridden with this argument.
SetTransformAccess(Jobs.TransformAccess, Vector3, bool)
Set the position without causing a to be generated. See .
Params:
transformAccess — The used to change the transform.
position — The global position to set the transform to.
transformChangedEvent — By default, no transform changed event will be produced however this behaviour can be overridden with this argument.
SetTransformAccess(Jobs.TransformAccess, Vector3, Quaternion, bool)
Set the position and rotation without causing a to be generated. See .
Params:
transformAccess — The used to change the transform.
position — The global position to set the transform to.
rotation — The global rotation to set the transform to.
transformChangedEvent — By default, no transform changed event will be produced however this behaviour can be overridden with this argument.
SetTransformWriteTweens(ReadOnlySpan{Unity.U2D.Physics.PhysicsBody.TransformWriteTween})
Sets all the Transform Write Tweens to be handled per-frame. See and .
Params:
transformWriteTweens — The new transform write tweens to be used.
Simulate(float)
Simulate the world. If is zero then only contact and trigger events will be updated and no velocity or position integration or constraint updates will occur.
Params:
deltaTime — The amount of time to forward simulate the world.
Simulate(ReadOnlySpan{Unity.U2D.Physics.PhysicsWorld}, float)
Simulate a batch of worlds. If is zero then only contact and trigger events will be updated and no velocity or position integration or constraint updates will occur. The worlds can be simulated concurrently depending on the setting of .
Params:
worlds — The worlds to forward simulate.
deltaTime — The amount of time to forward simulate the world.
TestOverlapAABB(PhysicsAABB, PhysicsQuery.QueryFilter)
Tests if the provided AABB potentially overlaps any shapes. The overlap is between AABB of shapes in the world therefore it may not result in an exact overlap of any shape itself. See and .
Params:
aabb — The AABB used to check overlap. This must be in world-space.
filter — The filter to control the result returned.
Returns: If the query overlaps anything.
TestOverlapAABB(ReadOnlySpan{Unity.U2D.Physics.PhysicsAABB}, PhysicsQuery.QueryFilter)
Tests if the provided AABBs potentially overlap any shapes. The overlap is between AABB of shapes in the world therefore it may not result in an exact overlap of any shape itself. See and .
Params:
aabbs — The AABB used to check overlap. These must be in world-space.
filter — The filter to control the result returned.
Returns: If the query overlaps anything.
TestOverlapGeometry(CircleGeometry, PhysicsQuery.QueryFilter)
Tests if the provided Circle geometry overlaps any shapes. A circle with a radius of zero is equivalent to . See and .
Params:
geometry — The Circle geometry used to check overlap. This must be in world-space.
filter — The filter to control the result returned.
Returns: If the query overlaps anything.
TestOverlapGeometry(ReadOnlySpan{Unity.U2D.Physics.CircleGeometry}, PhysicsQuery.QueryFilter)
Tests if the provided Circle geometry overlaps any shapes. A circle with a radius of zero is equivalent to . See and .
Params:
geometry — The Circle geometry used to check overlap. These must be in world-space.
filter — The filter to control the result returned.
Returns: If the query overlaps anything.
TestOverlapGeometry(CapsuleGeometry, PhysicsQuery.QueryFilter)
Tests if the provided Capsule geometry overlaps any shapes. See and .
Params:
geometry — The Capsule geometry used to check overlap. This must be in world-space.
filter — The filter to control the result returned.
Returns: If the query overlaps anything.