Select Units - Learn Godot 4 2D - no talking

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ต.ค. 2024

ความคิดเห็น • 20

  • @ham130.
    @ham130. 2 หลายเดือนก่อน +1

    thanks for this toturial

  • @OLMQ-01
    @OLMQ-01 2 หลายเดือนก่อน +1

    thank you very much!

  • @carlonsantosalberto3590
    @carlonsantosalberto3590 2 หลายเดือนก่อน +1

    DevDrache podes hacer algo perecido a Mario Bros montando a Yoshi gracias por los tutoriales

    • @DevDrache
      @DevDrache  2 หลายเดือนก่อน +1

      Do you mean the part where Mario jumps on Yoshi and uses him?

    • @carlonsantosalberto3590
      @carlonsantosalberto3590 2 หลายเดือนก่อน +1

      @@DevDrache si esa versión porque no hay muchos tutoriales que lo expliquen bien gracias por los tutoriales de siempre

    • @DevDrache
      @DevDrache  2 หลายเดือนก่อน +1

      sure, i put it on my list :)

    • @carlonsantosalberto3590
      @carlonsantosalberto3590 2 หลายเดือนก่อน

      @@DevDrache gracias

  • @TrekYourself80
    @TrekYourself80 2 หลายเดือนก่อน +1

    Could the "await get_tree().create_timer(0.04).timeout" instead just be "await get_tree().physics_frame"? I think that's all you need in order to wait for the collision physics to catch up to the changes you're making in moving the collision shape.
    Also, I'd be interested in seeing how this would be done in a 3D way, if it's at all different.

    • @DevDrache
      @DevDrache  2 หลายเดือนก่อน +1

      I thought the same at first, but it didn't always work with a await physical frame alone.
      I think with 2 await physic frames it was ok.
      And then I decided to add something safe to the video :)
      3d variant is now on my list.

  • @vartem123
    @vartem123 15 วันที่ผ่านมา

    Thanks!
    But how do you select one unit only?
    With
    func _select_one_unit():
    var currentMouse = get_global_mouse_position()
    for body in currentMouse:
    if body in get_tree().get_nodes_in_group("unit"):
    body.selected = true
    and input call
    I am getting a delay, so I have to click longer. Can't get it.

    • @DevDrache
      @DevDrache  14 วันที่ผ่านมา +1

      You only have to put the area2D on the mouse position and downsize the collision shape of the area.
      like this (not tested):
      func _select_one_unit():
      selection_area.global_position = get_global_mouse_position()
      collision_shape_2d.shape.size = Vector2.ONE # maybe more?
      await get_tree().create_timer(0.04).timeout
      var units = get_tree().get_nodes_in_group("unit")
      for body in selection_area.get_overlapping_bodies():
      if body in units:
      body.selected = true
      units.erase(body)
      for body in units:
      body.selected = false

  • @rageevil1972
    @rageevil1972 หลายเดือนก่อน

    How do i add a click to move the units? When you just click it clears the units.

    • @DevDrache
      @DevDrache  หลายเดือนก่อน

      The following video explains it:
      th-cam.com/video/L03UWTLF9kw/w-d-xo.html
      It's basically part 2

  • @lmkpk1694
    @lmkpk1694 28 วันที่ผ่านมา

    Thanks for this toturial. But i found that i coundn't select unit. When i open "Show collision area", the collision area doesn't move when i am selecting units. I want to ask is this a problem?

    • @DevDrache
      @DevDrache  28 วันที่ผ่านมา

      yeah this is a problem.
      die Collision shape of the "SelectionArea" should move after the selection.
      the "_select_units" function ensures that the collision moves, adjusts its size and selects the units in the collision

    • @lmkpk1694
      @lmkpk1694 28 วันที่ผ่านมา

      ​@@DevDrache Thank you. The collision shape's problem was solved. But it show error in func _get_rect_start_positon(),it show that "Invalid assignment of property or key 'x' with value of type 'float' on a base object of type 'Nil'.".If i change it to "var newPosition : Vector2", the start position of the collision shape will always be (0,0). Also, units still can not be selected.

    • @lmkpk1694
      @lmkpk1694 28 วันที่ผ่านมา

      @@DevDrache i think it is the problem of selectionStartPoint. i use print to check it. i dont know why it is always (0,0).

    • @lmkpk1694
      @lmkpk1694 28 วันที่ผ่านมา

      @@DevDrache Oh i fix it.I reversed the order of two lines of code.Thank you so much.

    • @DevDrache
      @DevDrache  28 วันที่ผ่านมา

      good work :)