Error recieved__ Invalid call. Nonexistent function 'set_pitch_scale' in base 'GDNativeClass'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kc
:warning: Old Version Published before Godot 3 was released.

Hi there
I have an Error.
I am always interested in what a particular error might actually mean.

and this error,
Invalid call. Nonexistent function ‘set_pitch_scale’ in base ‘GDNativeClass’.

seems rather interesting to me.
I have incuded a link to the Docs regarding the GDNativeClass
http://docs.godotengine.org/en/latest/classes/class_gdnativeclass.html#class-gdnativeclass-new

However I have no idea what that means.

Would anyone who understands what that means like to make a go at describing what the GDNativeClass is,

and what the error means?

PS the function call was inside an Extends Rigidbody2d script.

:bust_in_silhouette: Reply From: Zylann

When you call a method in GDScript (here set_pitch_scale), it will look at the type of the object, and see if the method can be found. If it’s not there, then it will look for the parent class. If it’s still not there, it will look for the grand-parent etc until the top-most class of the inheritance hierarchy is reached.

In your case, you tried to call set_pitch_scale on an object that didn’t have this function, and whose top-most class is GDNativeClass, which obviously doesn’t have it either.

Make sure the object you call this on is a SamplePlayer. Either by inheriting it, or by getting a reference to it so you can call it from somewhere else, like this:

var sample_player = get_node("relative/path/to/sampleplayer")
sample_player.set_pitch_scale(voice, pitch)

GDNativeClass probably means you tried to call this on an object whose class is defined in GDScript. If you mind showing your code we can eventually tell you more about it.

Awesome again.

I am very happy to post all my code.
Although, I will have a crack at this problem first…

and the winning prize goes to code base 6 million with the hit song “plinking bings”

randomize()

var voice = get_node("relative/path/to/sampleplayer").play("smpl")
var sonic = get_node("relative/path/to/sampleplayer")
var pitchRandom = rand_range(0.01, 4)
sonic.set_pitch_scale(voice, pitchRandom)

by which I mean that the code immediately above here works to play a sound an change the pitch

kc | 2017-02-22 21:56