0 votes

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 'setpitchscale' 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.

in Engine by (22 points)

1 Answer

+2 votes

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.

by (29,036 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.