How to make a circular mesh?

Godot Version

4.2.2

Question

Hello, I am trying to make a forcefield effect that is a circle. I have had great results making effects using meshes of other shapes. But I can’t seem to figure out how to make a circle mesh. There’s a sphere shape for the MeshInstance2D, but my research leads me to believe that you should not use that for 2D games, so now I’m not really sure what to do? How are you supposed to do this? Why is there not a circle option?

You can use ImmediateMesh

Documentation of MeshInstance2D says:

Node used for displaying a Mesh in 2D

Why shouldn’t it be used in 2D games?

1 Like

Well, to be honest there isn’t any information anywhere about sphere mesh as far as I can tell, the only related stuff I can find is that you shouldn’t.try.ro render anything 3D in Godot’s 2D engine because it’s not meant for that and can cause issue.

I assume that if it was meant to be used to render a 2D shape, it would be called circle as not sphere.

What other 2D meshes have you been using? What makes the sphere worse than the other meshes?

You could make a Line2D or Polygon2D circular through code

extends Line2D

func make_circle(fidelity: int, radius: float) -> void:
	var temp_points: PackedVector2Array = []
	for i in range(fidelity):
		var angle: float = float(i) * TAU / fidelity
		var x: float = cos(angle) * radius
		var y: float = sin(angle) * radius
		temp_points.append(Vector2(x, y))
	points = temp_points

Okay, then I don’t understand what you’re trying to achieve.

By default both 3d and 2d can be used.

If you want to have a plane circle in 2d, use for example MeshInstance2D or a simple Sprite2D.

As an example you could also have a 3d world with an orthogonal camera that looks like 2d but is 3d.

Try to describe your concrete problem.

My issue is that I cannot figure out how to make a circular mesh, because there isn’t an option for it in MeshInstance2D.

I have been using Quad meshes so far. And that’s definitely an interesting idea, I’ll probably combine that with the instant mesh to see what I can do

1 Like

I see, might get to use PRIMITIVE_TRIANGLE_STRIP good luck! I am interested in what you are doing with your quads too!

1 Like

A MeshInstance2d can represent any mesh.
You can make your own in blender, import it and use it in your mesh instance.

That’s the general way to use custom meshes. You can also generate them via code and create a mesh in GDScript for example.

1 Like

I would try to avoid instant meshed wherever I can.
That’s not how you want to manage your meshes since your using a high-level engine.

1 Like

I think that information is outdated, if it was ever valid to begin with. All the MeshInstance2D shapes are based on their 3D counterparts, so that is not specific to the sphere mesh. If the other shapes work, the sphere is likely to work as well.

You should try it and see if it works. It’s the best way to learn.