How to specify exported NodePath type?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ruckus T-Boom

Is there a way to specify the type of a NodePath?

Say I have export(NodePath) var target, is there a way I can specify target should be a KinematicBody,, etc.?

:bust_in_silhouette: Reply From: eons

No, there is no way to filter by class.

If you need a restriction to avoid mistakes you can make a setter that checks, prints an error and ignore nodes of the incorrect type.

:bust_in_silhouette: Reply From: Multirious

from (Mine)

You can do this by using _get_property_list()

func _get_property_list() -> Array:
    return [

At hint=35 is not in the docs; I found it from here

I have no idea how to do it for export key-word, though. Trying

export(NodePath, 'Node') var test: NodePath

return an error
Parse Error: Type "NodePath" can't take hints.
Advance export docs

Yes! This is the correct approach. However, you constant is wrong. It should be


The full code is then:

func _get_property_list() -> Array:
    return [
            "name": "sprite",
            "type": TYPE_NODE_PATH,
            "usage": PROPERTY_USAGE_DEFAULT,
            "hint_string": "Sprite"

Juxxec | 2023-04-06 10:18