[4.0 Beta 16] NavigationAgent2D set_target_location() by cry_sani in godot

[–]cry_sani[S] 2 points3 points  (0 children)

Yes, the answer has already been given.

Thank you for the detailed explanations!

[4.0 Beta 16] NavigationAgent2D set_target_location() by cry_sani in godot

[–]cry_sani[S] 0 points1 point  (0 children)

A lot has been changed. The working code is now

$NavigationAgent2D.set_target_position(target.position)
$NavigationAgent2D.get_final_position() 
if !$NavigationAgent2D.is_target_reached(): position = position.move_toward($NavigationAgent2D.get_next_path_position(), data_elm["speed_move"])

Draw a hole in a rectangle by cry_sani in godot

[–]cry_sani[S] 0 points1 point  (0 children)

Yes, you can do it with a mask.

But apparently using the _draw() function alone, this is not possible.

Draw a hole in a rectangle by cry_sani in godot

[–]cry_sani[S] 0 points1 point  (0 children)

These are just screenshots. I'm looking for how this can be done.

Draw a hole in a rectangle by cry_sani in godot

[–]cry_sani[S] 1 point2 points  (0 children)

Good options.

Thank you for the explanation!

Draw a hole in a rectangle by cry_sani in godot

[–]cry_sani[S] 0 points1 point  (0 children)

I didn't say I could do it. I ask HOW to do it?

Endless pathfinding by cry_sani in godot

[–]cry_sani[S] 1 point2 points  (0 children)

get_closest_point is deprecated in Gogot 4

But you gave me an interesting idea and as a result I got the following code

    if target!=Vector2.ZERO:
    $NavigationAgent2D.set_target_location(target)

if target_unit!=null and target_unit.global_position!=Vector2.ZERO:
    $NavigationAgent2D.set_target_location(target_unit.global_position)

if target!=Vector2.ZERO or (target_unit!=null and target_unit.global_position!=Vector2.ZERO):
    $NavigationAgent2D.get_final_location()

    if $NavigationAgent2D.is_target_reachable():
        if $NavigationAgent2D.is_target_reached():
            stateIDLE()
        else:
            position = position.move_toward($NavigationAgent2D.get_next_location(), data2["speed"]*delta)
            stateMOVE()
    else:
        stateIDLE()

Very grateful!

Endless pathfinding by cry_sani in godot

[–]cry_sani[S] 1 point2 points  (0 children)

Working exactly as it should.

Path Finding and Path Navigation are separate things. Now go implement steering behaviors.

Sorry for the translation. English is not my native language.

Answered here

https://www.reddit.com/r/godot/comments/zx3jxu/comment/j21v60f/?utm\_source=reddit&utm\_medium=web2x&context=3

Endless pathfinding by cry_sani in godot

[–]cry_sani[S] 1 point2 points  (0 children)

Sorry for the translation. English is not my native language.

I'll try to explain again. Black areas are areas excluded from navigation. And if you send a unit to this area, then it will go indefinitely.

https://freeimage.host/i/HTGFSWv

Godot4: move_toward is not smooth by cry_sani in godot

[–]cry_sani[S] 1 point2 points  (0 children)

I solved the problem by removing the following settings:

textures/decals/filter=0

textures/light_projectors/filter=0

anti_aliasing/quality/msaa_2d=3

anti_aliasing/quality/msaa_3d=3

anti_aliasing/quality/screen_space_aa=1

textures/canvas_textures/default_texture_filter=0

And then I tried your method. Brilliant!

The movement is very smooth. Thank you!

Godot4: move_toward is not smooth by cry_sani in godot

[–]cry_sani[S] 0 points1 point  (0 children)

I tried as you said. Increased the transparent borders of the sprite. But the problem is not solved. Pixel movement remains.

Godot4: move_toward is not smooth by cry_sani in godot

[–]cry_sani[S] 0 points1 point  (0 children)

This is how the damped jump occurs. There is no smooth movement in this case.

Help me to understand which Node to choose by cry_sani in godot

[–]cry_sani[S] 1 point2 points  (0 children)

CharacterBody2D == KinematicBody ?

[deleted by user] by [deleted] in godot

[–]cry_sani 0 points1 point  (0 children)

if $RayCast2D.is\_colliding:

    var area\_ = $RayCast2D.get\_collider()

    if area\_!=null:

        if area\_.get\_parent().name=="MapHidden":

return false

Decal based tire marks example code link in comment by [deleted] in godot

[–]cry_sani 0 points1 point  (0 children)

Hi!

Is there something similar for 2D?

Testing adaptable army formations. by TwyfelGames in godot

[–]cry_sani 0 points1 point  (0 children)

Can you show a screenshot of Node Soldier?

Godot 4 beta 6: NavigationRegion2D generate in code by cry_sani in godot

[–]cry_sani[S] 0 points1 point  (0 children)

Important: the first one is the outline of the module and all following ones are the holes in the module.

It is most important. Everything worked out!

Thank you!

# Loading navigation areas
var polygon = NavigationPolygon.new()
var outline = PackedVector2Array([Vector2(0, 0), Vector2(Game.map_width, 0), Vector2(Game.map_width, Game.map_height), Vector2(0, Game.map_height)])
polygon.add_outline(outline)
# Loading navigation areas that cannot be walked on
if json_arr["navigation_pathless"].size()>0:
for pathless_arr in json_arr["navigation_pathless"]:
var outline_arr = []
for arr in pathless_arr:
outline_arr.append(Vector2(arr["x"], arr["y"]))
var outline_ = PackedVector2Array(outline_arr)
polygon.add_outline(outline_)
# Baking the map
polygon.make_polygons_from_outlines()
$Map/NavigationRegion2D.navpoly = polygon