Scripting API
Scripting API
Collision2D
Record struct in Abyss.Physics2D, from Abyss.Physics2D.
Two bodies whose colliders began or stopped touching: Physics2D.CollisionsEntered and Physics2D.CollisionsExited. A body is an entity with a Rigidbody 2D and the colliders on it and under it, or ground: an entity with colliders and no Rigidbody 2D at or above it. Which is Collision2D.A and which Collision2D.B says nothing; Collision2D.Other and Collision2D.NormalToward ask from one side.
public readonly record struct Collision2DConstructors
Collision2D
public Collision2D(ulong A, ulong B, ulong ColliderA, ulong ColliderB, Vector2 Point, Vector2 Normal)Two bodies whose colliders began or stopped touching: Physics2D.CollisionsEntered and Physics2D.CollisionsExited. A body is an entity with a Rigidbody 2D and the colliders on it and under it, or ground: an entity with colliders and no Rigidbody 2D at or above it. Which is Collision2D.A and which Collision2D.B says nothing; Collision2D.Other and Collision2D.NormalToward ask from one side.
Parameters
A: One of the two bodies.B: The other.ColliderA: The entity ofA's collider that touched first, or parted last:Aitself, or one under it.ColliderB: The entity ofB's collider that touched first, or parted last.Point: Where they met, in world space: the middle of their contact points. Zero where they parted.Normal: The direction fromAintoBthey met along, a unit long. Zero where they parted.
Properties
A
public ulong A { get; init; }One of the two bodies.
B
public ulong B { get; init; }The other.
ColliderA
public ulong ColliderA { get; init; }The entity of A's collider that touched first, or parted last: A itself, or one under it.
ColliderB
public ulong ColliderB { get; init; }The entity of B's collider that touched first, or parted last.
Point
public Vector2 Point { get; init; }Where they met, in world space: the middle of their contact points. Zero where they parted.
Normal
public Vector2 Normal { get; init; }The direction from A into B they met along, a unit long. Zero where they parted.
RelativeVelocity
public Vector2 RelativeVelocity { get; init; }How fast Collision2D.B went against Collision2D.A where they met, in meters a second: its velocity there less A's, as they went into the step that began it; for a pair touching now, as they go now. Its length is how hard they hit: an impact sound's loudness, a fall's damage. Zero where they parted.
Methods
Involves
public bool Involves(ulong entity)Whether entity is one of the two bodies, or one of the two colliders.
Parameters
entity
Other
public ulong Other(ulong entity)What entity — a body, or its collider — touched: the other body.
Parameters
entity
OtherCollider
public ulong OtherCollider(ulong entity)The collider of the other body that entity — a body, or its collider — touched.
Parameters
entity
NormalToward
public Vector2 NormalToward(ulong entity)The normal of the surface entity — a body, or its collider — met, pointing out of the other into it: up, for something landing on the ground.
Parameters
entity
