Having difficulty checking if CollisionShape3D's Shape is a CapsuleShape3D

Godot Version: 4.4

extends Area3D

@export var VolumeShape : CollisionShape3D
var cylinder_length : float = 0.0

func _ready() -> void:
	if not VolumeShape == null:
			var volume_shaped = VolumeShape.get_shape()
			print(volume_shaped)
		if VolumeShape.shape == CapsuleShape3D:
			cylinder_length = volume_shaped.height - (volume_shaped.radius * 2)
			print(cylinder_length)

VolumeShape is set, and print(volume_shaped) does say it’s a CapsuleShape3D, however if VolumeShape.shape == CapsuleShape3D: behaves as if it is not.
(Even if .shape is replaced with .get_shape() or if VolumeShape.shape is replaced with volume_shaped)

I feel a bit dumb… But, I appreciate any help as I’ve been failing to figure it out… :')

To check the class type, use is instead of ==.

1 Like