Hello,

  1. In my minimap, i'd like to have only the world without any items. When my map is generated, is it possible to "update" the minimap's viewport but only once, before to add the items ?

  2. If not, i will need to take a screenshot of this map to use it on a textureRect node, but the map is already in a viewport, so it is hidded, what can i do, in this case ?

  • TwistedMind
    Try adding a yield to let the viewport draw.

    yield(VisualServer, 'frame_post_draw')

You can use the function get_texture() and set that to the texture on the TextureRect. This will update live, but it is only rendered once so should not affect performance much. If you want to save it, use get_data() and create a new Image.

    Hi, cybereality,

    Agreed. Why the last line works and not by a variable and why the last line update the textureRect like a viewport ? It shouldn't.

    extends Viewport
    
    func _ready():
    	world_2d = get_parent().get_parent().get_node("vpGame").world_2d
    	#var img = get_texture().get_data()
            #img.flip_y()
    	#get_parent().get_parent().get_node("Minimap/TextureRect").set_texture(img)
    	get_parent().get_parent().get_node("Minimap/TextureRect").set_texture(get_texture())
    6 days later

    Yes, so that's mean i need to create a new "live" texture:

    • First, i catch what vpConCam show, as image;
    • Them, i need to flip it because it must be done;
    • I make a new static texture (i suppose) and i create it from the image checked;
    • Finally i apply this new static texture on the textureRect.

    But the minimap corner still empty... why ? The last step doesn't supposed to make a new texture ? An imageTexture is a texture right ?

    edit: it seems the _ready function doesn't allow to do that. I tried with a timer node (with timer time out signal) and the code works... Now why it can works in the ready function is the question.

      TwistedMind
      Try adding a yield to let the viewport draw.

      yield(VisualServer, 'frame_post_draw')

        Hi, duane ,

        ...And put in just before the making texture process. So there is the goal of yield...

        It works too, nice !!!

        So that means the system need a little moment to initialize the tree and making the texture between the process doesn't works because of that. It can be logic.

        Thank you duane, cybereality