Can I have a MeshInstance C++ class member variable?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kovacsur10

I am new to Godot engine, and I’m trying to create a C++ module. Is it possible to have a MeshInstance variable in a class that is exposed to the editor as well (like a property)?

:bust_in_silhouette: Reply From: hungrymonkey

you add it to bind_methods

DD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE, "0.01,32,0.01"), "set_pitch_scale", "get_pitch_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "is_playing");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");

here is an example for audiostreamplayer

Ref< MeshInstance > is not valid, since MeshInstance is not a child of Reference (it’s a Node). On the other hand AudioStream has Reference as a parent class (Inherits: Resource < Reference < Object). That’s why I could not achieve to use the same method you mentioned.

kovacsur10 | 2018-04-24 16:04

you dont need to wrap it in Ref thou.

You can pass object *

Is your module managing the object? If so, look on how RID works so you will not have object ownership problems.

Custom Godot servers — Godot Engine (latest) documentation in English

RID — Godot Engine (latest) documentation in English

hungrymonkey | 2018-05-09 23:32