From 75af9003dc2b1583966ab91be6ce1687378860ae Mon Sep 17 00:00:00 2001 From: David Snopek Date: Sat, 11 Feb 2023 17:16:59 -0600 Subject: [PATCH] Fix Object::cast_to() for custom classes --- include/godot_cpp/core/object.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index f5c790aa..a2fa96e7 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -142,7 +142,7 @@ T *Object::cast_to(Object *p_object) { if (casted == nullptr) { return nullptr; } - return reinterpret_cast(internal::gde_interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); + return dynamic_cast((Object *)internal::gde_interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); } template @@ -155,7 +155,7 @@ const T *Object::cast_to(const Object *p_object) { if (casted == nullptr) { return nullptr; } - return reinterpret_cast(internal::gde_interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); + return dynamic_cast((Object *)internal::gde_interface->object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); } } // namespace godot