struct Godot::PhysicsHit3D

Overview

Strongly-typed 3D physics intersection hit result.

Encapsulates collision location, surface normal, and hit object reference with built-in dead-pointer protection.

Usage Example:

if hit = raycast(Vector3.forward, distance: 20.0)
  if destructible = hit.collider.as?(DestructibleProp)
    destructible.shatter!
  end
end

Defined in:

libgodot/extensions/physics.cr

Constructors

Instance Method Summary

Instance methods inherited from class Object

try?(&)
try?
try?

Constructor Detail

def self.new(point : Vector3, normal : Vector3, collider : Godot::Object | Nil = nil, rid : RID = RID.new, shape : Int32 = 0) #

Instance Method Detail

def collider : Godot::Object | Nil #

Returns the hit collider if alive, or nil if already freed or absent.

Dynamically verifies #alive? to guarantee dead-pointer safety. Pair with .as?(Type) for type-safe dispatch.


def normal : Vector3 #

The surface normal vector at the intersection point


def point : Vector3 #

The global intersection coordinate


def rid : RID #

The RID of the colliding physics body or shape


def shape : Int32 #

The shape index within the colliding body