Syntax Error C#

Godot Version

4.2.1 Mono

Question

Just recently switched over to scripting with C# however things don’t appear to be working the same. I’m trying to sample a noise using get_noise_2d() which works flawlessly in GDScript however when i try to implement the same code in C# it is telling me that neither Noise or FastNoiseLite have a function get_noise_2d and i cannot build… I found one tutorial online that was using GetNoise2d() instead of the familiar syntax however that provided me with the same error. What am i doing wrong here?

show us your code

using Godot;
using System;

public partial class WorldGen : TileMap
{
	public FastNoiseLite noise = new();
	
	public override void _Ready(){
		for (int x = 1;x <= 100; x++){
				for (int y = 1;y <= 100; y++){
					noise.get_noise_2d(x,y);
				}
		}	
	}

CS1061: ‘FastNoiseLite’ does not contain a definition for ‘get_noise_2d’ and no accessible extension method ‘get_noise_2d’ accepting a first argument of type ‘FastNoiseLite’ could be found (are you missing a using directive or an assembly reference?) C:\Users\travi\Godot Projects\TheAscent\WorldGen.cs(11,12)

figuring out how to do something in c# can be a thorn. in visual studio i typed ‘2d’ after noise. and it suggested the below. noise.GetNoise2D(x,y); should be it.

Untitled

Thats the other thing i tried as mentioned in initial post.
Still returns same error but with that method name instead

CS1061: ‘FastNoiseLite’ does not contain a definition for ‘GetNoise2d’ and no accessible extension method ‘GetNoise2d’ accepting a first argument of type ‘FastNoiseLite’ could be found (are you missing a using directive or an assembly reference?) C:\Users\travi\Godot Projects\TheAscent\WorldGen.cs(11,12)

Edit: OMG it was the d in 2d… it needs to be uppercase

Thats what i get for attempting to use the Godot built in text editor. going back and forth and recompiling was getting cumbersome so i thought id try to just do it in editor but i definitely would have caught that if i was using my VS Code…

1 Like

LOL thanks for the chuckle. Cheers.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.