godotengine / godotengine/godot-cpp

Runtime classes cannot be cast_to from non runtime classes

Open
#1,419 2 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### Godot version

4.3.dev (dad6c774b0)

### godot-cpp version

4.3.dev (e55b792fea)

### System information

Windows 10

### Issue description

Noticed this when creating an EditorGizmo for a new node type - a node that is gameplay focused and ideally should be tagged runtime.

```
bool BuildAnchorGizmoPlugin::_has_gizmo(Node3D *for_node_3d) const {
return Object::cast_to(for_node_3d) != nullptr;
}
```
would always return false until I changed the registration.

### Steps to reproduce

1. Create and register a runtime class: e.g.
`ClassDB::register_runtime_class();`

2. Create and register a non-runtime class: e.g.
`ClassDB::register_class();`

3. In second class, attempt to cast a given node:
`BuildAnchor *anchor = Object::cast_to(gizmo->get_node_3d());`

`anchor` will always be `nullptr`.

### Minimal reproduction project

Can provide if necessary.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.