GLTFCollider

Inherits: Resource < Reference < Object

Represents a GLTF collider.

Description

Represents a collider as defined by the OMI_collider GLTF extension. This class is an intermediary between the GLTF data and Godot's nodes, and it's abstracted in a way that allows adding support for different GLTF physics extensions in the future.

Tutorials

Properties

ArrayMesh

array_mesh

float

height

2.0

bool

is_trigger

false

int

mesh_index

-1

float

radius

0.5

String

shape_type

""

Vector3

size

Vector3( 1, 1, 1 )

Methods

Dictionary

to_dictionary ( ) const

CollisionShape

to_node ( bool cache_shapes=false )


Property Descriptions

ArrayMesh array_mesh

The ArrayMesh resource of the collider. This is only used when the collider type is "hull" (convex hull) or "trimesh" (concave trimesh).


float height = 2.0

  • void set_height ( float value )

  • float get_height ( )

The height of the collider, in meters. This is only used when the collider type is "capsule" or "cylinder". This value should not be negative, and for "capsule" it should be at least twice the radius.


bool is_trigger = false

  • void set_is_trigger ( bool value )

  • bool get_is_trigger ( )

If true, indicates that this collider is a trigger. For Godot, this means that the collider should be a child of an Area3D node.

This is the only variable not used in the to_node method, it's intended to be used alongside when deciding where to add the generated node as a child.


int mesh_index = -1

  • void set_mesh_index ( int value )

  • int get_mesh_index ( )

The index of the collider's mesh in the GLTF file. This is only used when the collider type is "hull" (convex hull) or "trimesh" (concave trimesh).


float radius = 0.5

  • void set_radius ( float value )

  • float get_radius ( )

The radius of the collider, in meters. This is only used when the collider type is "capsule", "cylinder", or "sphere". This value should not be negative.


String shape_type = ""

  • void set_shape_type ( String value )

  • String get_shape_type ( )

The type of shape this collider represents. Valid values are "box", "capsule", "cylinder", "sphere", "hull", and "trimesh".


Vector3 size = Vector3( 1, 1, 1 )

The size of the collider, in meters. This is only used when the collider type is "box", and it represents the "diameter" of the box. This value should not be negative.


Method Descriptions

Dictionary to_dictionary ( ) const

Serializes this GLTFCollider instance into a Dictionary.


CollisionShape to_node ( bool cache_shapes=false )

Converts this GLTFCollider instance into a Godot CollisionShape node.