yikescloud because this way uses Navigation2DPolygonInstance and it must be in the World node. If you put the simple_path function in an Enemy node, you must use Navigation2D by Tilemap. But the way Tilemap is too complicated for me. Do you have a way in this direction that is simple? Or simply code in Tilemap style. Because the clips on Youtube make the Tilemap style so confusing.

    Odin You can use it in the enemy. Just like this:

    extends KinematicBody2D
    onready var nav:Navigation2D = get_node("../../NavigationPolygon")
    
    func _process(delta):
        nav.get_simple_path(self.position,$Player.position)
    • Odin replied to this.

      yikescloud Unfortunately it doesn't work. If OK, can you give me an example code to help me in that case?Sincerely thank you very much. Sorry I'm new to coding too. ^^

      I just do this in my game, I use both navigationPolygonInstance and Tilemap same time, it's below the navigation2D node, and it just works fine.

      func navigate_point(var _p:Vector2) -> Vector2:
      	var _path = _Navigator.get_simple_path(position, _p)
      	if _path.size() > 1:
      		return _path[1]
      	return _p

      Yeah, that's great. I really appreciate your great help, Yike! Sorry for my trouble.World's Script? Enemy's Script? What's the full take on this, Yike? I wonder if you'd be willing to show me the full code on this issue for me? All are just code related to this problem only.Once again thank you very much for your help. Best regards!

        Odin You dont need a world script for this. Later I will upload a demo project maybe

        • Odin replied to this.


          It still gives me a lot of errors, Yike? Is something wrong? This is the project you sent me. How will I fix it? and if i want Enemies to not only chase every Player, but they also chase everyone in the Player group, how do I add the which code? Using Groups? Sorry to bother you Yike! ^^

            Odin
            Fix the Error: change script in NavigationPolygonInstance like this:
            func draw_self():
            for i in navi_poly.get_outline_count():
            var _outline:PoolVector2Array = navi_poly.get_outline(i)
            if _outline.size() == 0:
            continue
            _outline.append(_outline[0])
            draw_polyline(_outline, Color.white, 5.0, false)

            Seems like get_polygon_count () return count of triangles but not the island.

            If you want chase other, just change this code in enemy process:

            var p = navigate_point(_Player.position)
            to
            var p = navigate_point(_player_group.get_nodes_in_group[player_index])

            • Odin replied to this.

              yikescloud
              That error is gone, now only the error on row 14 in Enemy's Script. Now what Yike?

                Odin Just comment this like you select. I thought I commented it already, maybe you uncomment it again?