Scripting API

Scripting API

Collision3D

Record struct in Abyss.Physics3D, from Abyss.Physics3D.

Two bodies whose colliders began, stopped or go on touching: Physics3D.CollisionsEntered, Physics3D.CollisionsExited and Physics3D.CollisionsStaying. A body is an entity with a Rigidbody 3D and the colliders on it and under it, or ground: an entity with colliders and no Rigidbody 3D at or above it. Which is Collision3D.A and which Collision3D.B says nothing; Collision3D.Other and Collision3D.NormalToward ask from one side.

public readonly record struct Collision3D

Constructors

Collision3D

public Collision3D(ulong A, ulong B, ulong ColliderA, ulong ColliderB, Vector3 Point, Vector3 Normal)

Two bodies whose colliders began, stopped or go on touching: Physics3D.CollisionsEntered, Physics3D.CollisionsExited and Physics3D.CollisionsStaying. A body is an entity with a Rigidbody 3D and the colliders on it and under it, or ground: an entity with colliders and no Rigidbody 3D at or above it. Which is Collision3D.A and which Collision3D.B says nothing; Collision3D.Other and Collision3D.NormalToward ask from one side.

Parameters

  • A: One of the two bodies.
  • B: The other.
  • ColliderA: The entity of A's collider that touched first, or parted last: A itself, or one under it.
  • ColliderB: The entity of B'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 from A into B they 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 Vector3 Point { get; init; }

Where they met, in world space: the middle of their contact points. Zero where they parted.

Normal

public Vector3 Normal { get; init; }

The direction from A into B they met along, a unit long. Zero where they parted.

RelativeVelocity

public Vector3 RelativeVelocity { get; init; }

How fast Collision3D.B went against Collision3D.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. Zero where they parted.

Impulse

public Vector3 Impulse { get; init; }

How hard they hit, as the impulse Collision3D.B was given, in newton-seconds: along the normal and, where they slid, across it — A was given as much the other way. Unlike the relative velocity it counts their masses, so a crate hitting hard counts for more than a pebble as fast: an impact sound's loudness, a fall's damage. Worked out as they began touching, from their velocities and their contact, before anything else touching either; zero where they parted, and for a pair in Physics3D.CollisionsStaying.

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 Vector3 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