KinematicCollision2D
The result of tested 2D body motion.
KinematicCollision2D contains contact data: collider, normal, travel and remainder. Check the MoveAndCollide result for null first. After MoveAndSlide, obtain results through GetSlideCollisionCount/GetSlideCollision.
GetTravel and GetRemainder differ: remainder continues motion not yet performed. Do not apply the original displacement again. Validate collider lifetime for deferred handling; a contact does not prevent a game object from being deleted.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
KinematicCollision2DConstructor
public KinematicCollision2D();Methods13
GetAnglefloat
public float GetAngle(Vector2? upDirection = default);Returns the collision angle according to up_direction, which is Vector2.Up by default. This value is always positive.
| Name | Type | Default |
|---|---|---|
upDirection | Vector2? | default |
upDirectionIf the parameter is null, then the default value is new Vector2(0.0f, -1.0f).
floatGetColliderReckfellObject
public ReckfellObject GetCollider();Returns the colliding body's attached ReckfellObject.
ReckfellObjectGetColliderIdulong
public ulong GetColliderId();Returns the unique instance ID of the colliding body's attached ReckfellObject. See ReckfellObject.GetInstanceId.
ulongGetColliderRidRid
public Rid GetColliderRid();Returns the colliding body's Rid used by the PhysicsServer2D.
RidGetColliderShapeReckfellObject
public ReckfellObject GetColliderShape();Returns the colliding body's shape.
ReckfellObjectGetColliderShapeIndexint
public int GetColliderShapeIndex();Returns the colliding body's shape index. See CollisionObject2D.
intGetColliderVelocityVector2
public Vector2 GetColliderVelocity();Returns the colliding body's velocity.
Vector2GetDepthfloat
public float GetDepth();Returns the colliding body's length of overlap along the collision normal.
floatGetLocalShapeReckfellObject
public ReckfellObject GetLocalShape();Returns the moving object's colliding shape.
ReckfellObjectGetNormalVector2
public Vector2 GetNormal();Returns the colliding body's shape's normal at the point of collision.
Vector2GetPositionVector2
public Vector2 GetPosition();Returns the point of collision in global coordinates.
Vector2GetRemainderVector2
public Vector2 GetRemainder();Unperformed displacement remaining after contact. For reflection, transform both velocity and this remainder; repeating the original segment would add excess travel.
Vector2GetTravelVector2
public Vector2 GetTravel();Returns the moving object's travel before collision.
Vector2