0 votes

Hi,
experimenting with godots 2d part I ran in a very simple problme I could not find a solution to: How do I set the z order for multimeshes? Particulraily, in the code example below, i'd like to set the zorder dependent on the y-coordinate. Did I miss something?

extends MultiMeshInstance2D

func _ready():
  self.multimesh.mesh = get_parent().mesh;
  for i in range(self.multimesh.instance_count):
    multimesh.set_instance_transform_2d(i, Transform2D(0.0, Vector2(float(randi()%2000), float(randi()%2000))));
  pass 
Godot version 3.3.2
in Engine by (16 points)

1 Answer

0 votes

well, multimesh2d just draws in the order of its instances.
if the order needs to be dependent on a coordinate:

  • if object coordinates stay stable, you can simply set the order accordingly.
  • If your objects move - you need to sort your instances according to the draw order you need, and then update the order dependingly... If you need to do this often, I can only assume there is heavy cost connected to such an approach - if noone disagrees with me I can only recommend against it...
by (16 points)
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 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 webmaster@godotengine.org with your username.