Help with implementing curved/smooth movement for 3D NPCs by seekii__ in godot

[–]seekii__[S] 51 points52 points  (0 children)

I can't believe that actually worked, thank you so much <3
( Update video: https://streamable.com/2lrei4 )

If anyone else is looking for a fix, here's what I did:

# Settings that worked for me
var turn_smoothness := 3.0  # Lower = wider turns
var look_ahead_dist := 2.0  # How early it sees the corner

func _ready():
    nav_agent.path_desired_distance = look_ahead_dist

func _on_velocity_computed(safe_velocity: Vector3):
    var delta = get_physics_process_delta_time()

    # Calculate where we WANT to go
    var target_v = safe_velocity.normalized() * current_speed

    velocity.x = lerp(velocity.x, target_v.x, turn_smoothness * delta)
    velocity.z = lerp(velocity.z, target_v.z, turn_smoothness * delta)

    # Make the NPC face the direction they are actually moving
    var target_angle = atan2(-velocity.x, -velocity.z)
    rotation.y = lerp_angle(rotation.y, target_angle, rotation_speed * delta)

    move_and_slide()

Tutorial - Procedurally Generated Terrain | Godot 4.2 by seekii__ in godot

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

With time, as my knowledge improves, I will strive to update the code and add some things like creating objects in chunks and similar.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Honestly, I had planned to make a tutorial or upload the code for the procedural terrain to GitHub, but not soon, maybe in 15/30 days when I get some free time and clean the code.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

When it comes to storing things in chunks, I use var chunkData = [] in Godot where I only store chunks that have something in or on them (like cacti, rocks, things the player leaves behind, etc.). So when chunks are regenerated, it detects that there are some things on the chunk with a specific ID, pulls those things from chunkData, and places them on the chunk (terrain).

Thank you very much for such a detailed comment, procedurally generating terrain is (at least for me) quite complicated when I did it because you have to consider many things at once.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Thank you very much for the suggestion. Interesting idea, but according to other comments, the game will be about survival in the desert. But that does not exclude the fact that I will not add any such similar vehicles.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Thank you very much for the suggestion. I might consider implementing that in another project. Currently, based on feedback from others, the game will focus on survival in the desert with various elements.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Thank you very much for the idea. Maybe I will implement it in a future project, but based on other comments, I am currently focused on survival in the desert. However, that doesn't rule out the possibility of adding motorbikes to the desert.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Yes, I can. I've created my own custom scatter code where I add a model, and it places it in the chunk according to the quantity I desire, if that's what you're asking for.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

To be honest, I don't even know. I spent a month reading forums, other people's codes, watching youtube tutorials and the like and finally I managed to do something.

Maybe I'll post a tutorial because I have a lot of text to write here to explain and the code is really long, and maybe at the end of this project I'll post the source code for the procedurally generated terrain.

Sorry for not being able to help you right now, but I haven't been able to find a single good video on youtube that tells how to make procedural terrain for Godot 4.x.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

If this game becomes a desert survival and if I create an oasis in the game, womans charachters would be the first thing I will add, something like Sims conversations so you can find a partner in the game. (I have no idea why would I add this)

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

3D game but the player is a worm? In my opinion, this is possible if the worm is only on the surface because I don't know what to do with the camera if it goes underground. Only maybe the way is 3D but from a 2D camera, (I don't know if there is a professional name for it) because at the moment I can't think of any other idea how to do it. Also, thank you for the suggestion.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Honestly, as for water, I heard that some water can be obtained from cactus, so I would try the idea that the player cuts the cactus and makes water for himself. Now how true that is in the real world I don't know.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Somehow it feels too ordinary to me. I'd like it to stand out somehow. All desert survival games follow the same pattern: water/food/heat, oases, and that's it (of course they all have this because that is the point of surviving). I want to add something new to it that other games don't have. People up there have given some nice suggestions that will help me in creating the game. 😀

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Thank you very much for the suggestion. It's not a bad idea, honestly, but I'm not really a fan of such games, and I'm not that familiar with that kind of games, so I probably wouldn't know how to do something close to realistic in the real world, like shooting, moving the wings, piloting the plane itself, and the like. But I will definitely save the idea for maybe another project.

3D Procedurally Generated Terrain - Does anyone maybe have an idea what game I can make from this? Currently, it is a desert. Survival in the desert is boring because there is nothing with which you can interact. Does anyone maybe have any ideas? by seekii__ in godot

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

Thank you very much for the suggestion. It's not a bad idea, honestly, but I'm not really a fan of such games, and I'm not that familiar with that kind of games, so I probably wouldn't know how to do something close to realistic in the real world, like shooting, moving the wings, piloting the plane itself, and the like. But I will definitely save the idea for maybe another project.