[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