How am i supposed to use a primitive from an addon?

Godot Version

Godot 4.7

Question

Ask your question here! Try to give as many details as possible.

If you share code, please wrap it inside three backticks or replace the code in the next block:

IcoSphere, IcoSphereMesh

Hi,

i downloaded and imported this addon Icosaedron Sphere (IcoSphere) Mesh - Godot Asset Library . I think it is supposed to add a icoshere primitive. Is that right ? But i tried to create one with the code above and i get error, type don’t exist… How am i supposed to install and use this primitive ?

Could you please replace that line with your godot version?

What is the exact error message you get, could you show us?
Can you also show us the code you used to try and use the addon?
Did you make sure it’s enabled in the project settings?

Here is the exact code type object = new type(); with type replaced by IcoSphereMesh, IcosphereMesh, IcoSphere, but even CSGMesh3D. All give this error CS0246: Le nom de type ou d’espace de noms ‘IcoSphereMesh’ est introuvable (vous manque-t-il une directive using ou une référence d’assembly ?) /home/work/Téléchargements/3d_squash_the_creeps_starter/Main.cs(22,3)

It has been enabled.

Here is the complete code

using Godot;
using System;

public partial class Main : Node
{
public override void _Ready(){
CreateBox();
}

private void CreateBox(){
	StaticBody3D bd = new StaticBody3D();
	MeshInstance3D mi = new MeshInstance3D();

	// 1. On DONNE une forme visuelle au MeshInstance3D (ici, un cube de 1m)
	PlaneMesh boxMesh = new PlaneMesh();
	boxMesh.Size = new Vector2(1000.0f, 1000.0f);
	boxMesh.SubdivideWidth = 10;
	boxMesh.SubdivideDepth = 10;
	mi.Mesh = boxMesh;
	
	//Icosphere
	IcoSphereMesh icosphere = new IcoSphereMesh();

	// On décale un peu l'objet pour ne pas qu'il apparaisse au centre du monde
	bd.Position = new Vector3(0, -10.0f, 0.0f);

	// Construction de la hiérarchie
	bd.AddChild(mi);
	AddChild(bd);
}

}

In your original post, you never once mentioned that you are using C#

As far as I can tell, it’s not possible to use a GDScript class inside C# that isn’t built-into the engine itself. You’d need to create a wrapper for it all, and given that the addon haven’t been updated in a few years, I’m not sure it’ll work well.

You are not using icosphere in your code here, what did you mean to do?

I did not add any code to use it, because it gives error. I am trying to generate a simple icosphere with c# script by the way.

I did not notice it could be for gdscript, thank for help.

How are you defining the GDScript type? It should be possible to use the type but it would depend on how it is defined (you can’t inherit a GDScript type for a C# type and vice versa though)

I don’t understand your question. I posted the script i am using. Also i am using an addon i downloaded, imported and enabled.

What I mean is how is the type defined in the addon? It might not be possible to use named classes from GDScript in C# and vice versa, you might need to reference it by the file, see this page

But it might depend on how the addon defines the class, is it defined with class_name?

Yes it is probably an addon writted in gdscript. The class is defined with class_name. So your link seems to be the solution, thanks