Missing method?

Godot Version



I have a C# script attached to a Node3D for player control.

Node3D node = GetNode<Node3D>("Player");

The above code exactly. Everything else in the script works as desired but I get the error

CS1061: ‘Node3D’ does not contain a definition for ‘get_global_rotation’ and no accessible extension method ‘get_global_rotation’ accepting a first argument of type ‘Node3D’ could be found (are you missing a using directive or an assembly reference?) G:\Godot Projects\TGWYJST\Player Scripts\movement.cs(23,8)

but the Godot documentation says that this (and set_global_rotation()) are commands that a Node3D should be fine with. I have no clue why this is not working, what am I missing?

Edit: Thank you all so much, it works now!

This may be a documentation issue.

Here is a similar question.

This is documented here:

In GDScript, the setters/getters of a property can be called directly, although this is not encouraged. In C#, only the property is defined. For example, to translate the GDScript code x.set_name(“Friend”) to C#, write x.Name = “Friend”;.

Just out of curiosity, do you (or anyone else) know why using setters/getters is “not encouraged” ?
They’re actually more performant than just doing x.Name = “Friend”.

They’re actually more performant than just doing x.Name = “Friend”.

What are you basing this on? The properties should be correctly compiled into the specific method, but either way I’d say any difference would be marginal, and would only apply for built-in properties

for script properties without explicit get/set methods you’d have better performance as the internal code accesses the properties as properties, AFAIK

1 Like

My own testing + I’ve seen others mention it somewhere (probably on these forums, but can’t find it now).
Yeah I meant built-in properties, and sure, it’s not a huge difference, but I started using setters/getters more when I found out and this is the first time I see that they’re not encouraged. I’m just wondering why.

1 Like

I don’t know of specific reasons, except that I think it works better when accessing properties on script classes due to how the compilation works

But regardless the reason they aren’t exposed in C# is because of the normal code standards for C#, i.e. in C# you don’t expose the access methods