Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Slice(FragmentGeometry, Vector2, Vector2, Allocator)

Slice the specified target geometry using the specified slice line. The target geometry is sliced using the specified ray as defined by origin and translation. The specified line segment origin and translation are extended to infinity and so defines a 2D intersection plane. All valid target geometry will returned in either the _leftGeometry or _rightGeometry depending on its side of the line (sliced or not). Left and Right are defined as "looking" along the ray in the direction defined by translation with Left being anything to the left of the ray and Right being anything to the right of the ray. See PhysicsDestructor.SliceResult.
Read time 2 minutesLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule
public static PhysicsDestructor.SliceResult Slice(PhysicsDestructor.FragmentGeometry target, Vector2 origin, Vector2 translation, Allocator allocator = Allocator.Temp)

Parameters

The target geometry to slice. There must be at least a single geometry element. Any target polygons with a non-zero radius will be ignored.

origin

The start of the ray slice line.

translation

The translation relative to the origin of the slice ray. This must have a non-zero magnitude.

allocator

The memory allocator to use for the results. This can only be Allocator.Temp, Allocator.TempJob or Allocator.Persistent.

Returns

Type

Description

SliceResultThe slice results. The transform returned here is the one provided in the target geometry. These results must be disposed of after use otherwise leaks will occur.