OMG getting the objects to face forward.. "direction_to".. I have to stop smacking my head before there's blood.. I was trying to move a ghost object along a dynamic follow path and use it's iterated position to place my instantiated objects.. which I really felt was a clever idea... but I was the only one lol. Cheers man, this was goooold.
Thanks for putting this together, I knew there had to be a better way to create tracks than individually tiling. This has been extremely useful-much appreciated.
So cool, great breakdown ! I always wondered how the "grind rail" mechanic was done in Jet Set Radio where you can jump on and out the rail at any point in space, in any direction, could be a nice follow up to this tutorial ;)
With the Godot 4 you also can place an object with full Transform3D with: sample_baked_with_rotation ( float offset=0.0, bool cubic=false, bool apply_tilt=false )
thank you so much for this extremely helpful, i am using 3.5.1 so it took me a while to find that i needed to use interpolate_baked() instead of sample_baked(), but it ended up working perfectly!!
Awesome vid, subbed! I learned precisely nothing because I've literally got a project (vid on my channel) with cars learning to drive round a track so I sat watching merrily nodding my head saying "that's right" repeatedly to my monitor. :) Keep it coming!
Wow your videos are mind blowing. I learned so much. Is there a way to use the Godot editor gizmos for paths and object transformation at runtime. A video to do that all at runtime would be amazing
Hey, very nice tutorial. One question regarding CSG is, that it is usually only used for prototyping. So this method probably isn't that feasible/fast enough if I want to do this during the game? Like for example generating a road a long a path similar how the last SimCity game did it.
I think it's one of those things where you can just use it and optimise later if performance becomes an issue. What you could do later if it is an issue, is calculate a set of transforms along the path, like with the mesh instance example, and use them to place vertices to generate your own mesh. If this video does well enough, I'll make a part two where we generate the mesh ourselves to avoid these potential performance issues. Hope this was helpful nonetheless!
@@crigz OK, thanks for the quick reply. If you ever run out of Video ideas, you could also continue this by adding a traffic system to the path. So that, for example, cars use the correct roadside and be aware of intersections (and maybe how to generate an intersection where side walks don't overlap) etc. :D
Was wondering the same thing about using custom mesh instead of CSG for performance. Another idea for a tutorial: adjust / flatten a terrain below the road to fit its shape.
There shouldn't be any significant difference between this and just having regular meshes. It's cached after all. What you shouldn't do is animating CSG to update your world constantly, as that will cause the stuff to be recreated/recalculated over and over again. IMO it's totally valid to use CSG outside prototyping, too, it's just about how you use it. As a matter of fact, Valve's source engine (Half-Life, Counterstrike, Team Fortress, etc.) is fully based on CSG for the environment. Their editor (Hammer) just "bakes" everything into static meshes when exporting, just like what Godot does when a CSG node is "dirty". Only downside when using static CSGs in Godot is the fact that they might load slower, since the geometry has to be calculated on the fly once first.
woah this is awesome. would it be possible to procedurally-generate a road on-the-fly? like, if you wanted to make some kind of infinite driving game where the road goes along forever with different variations that spawn in
Im having trouble holding shift+click to do the curves while using Top-Down view (It just doesnt happen, i have to use perspective, which is bad for "flat" tracks. Any tips or workarounds?
@@my_yt_ havent found a solution yet, but i ended up doing it on perspective mode, and manually changing the Y position to 0 on each point on the node's config.
would be nice tho have a different distribution according on how much changes are happening in the curvature. & having correct uvs at the same time. 😌 sounds like a side project for a pr!
Nice tutorial! I`m working in something like this, but multimesh for planks is new for me, one thing that I haven't had a solution so far if you can help me is that I would like to automatically place signs for curves (without placing it where it is straight road), how can I detect them? I needed to understand the size of the curve and if it is curved.
Thanks! Also, is there a way to copy the shape of the csg polygon and make a collision shape with the same shape. I need to create an area 3d with a collision shape that is formed based off a path but I haven't found a way to do so.@@crigz
Nice tutorial! What 'work'? is the CSG mesh doing? Would this method also work with a collection of 3D assets exported from, say, blender? Edit: I mean, you say 'Cubes' (for the tracks), but they are really squares. Does the path extrusion work if the model isn't 2 dimensional?
@@crigz Thanks for the reply! Do you think the 2D extrusion is robust enough for most applications? It feels a little weird to me to make stuff directly in Godot. I suppose a proper spline-mesh system could be created as a plugin/addon.
I think it will work great for anything which doesn't need its shape to vary along its length, like the roads and tracks in the vid. The benefit of doing it in Godot is how easy you can change and tweak things. A lesser known benefit of the CSG nodes though, is once you're happy with it in Godot you can export it as a GLTF file and polish the mesh up in blender.
Hey man, Really liked your video. Is there a way to remove the front and back face of the mesh being followed by the spline? I'm trying to generate a cave but I want the path to have a hole in the start and the end :)
a way to change the rotation of the tiled polygon ? i have water material applied to the path but the oriantation is wrong and it tiles next to each other instead of into each other ?
Great subject and well covered. Using the names of solids like "cube" when you were actually talking about 2d shapes was confusing and a little upsetting.
Amazing content! I noticed the label 3D's are always facing the editor camera at 4:50, how do you get the editor's camera? I tried scanning editor interface nodes and there are 3 cameras and no way of telling which one to use.
this video is very informative & educational. But, using "value_changed" instead using "is_dirty" could be more easy to understand function of that variable.👍
@tool extends Path3D @export var distance_between_planks: float = 0.6: get: return distance_between_planks set(value): distance_between_planks = value if not is_inside_tree(): await self.ready build_planks() func _ready() -> void: build_planks() func build_planks(): var path_lenght: float = curve.get_baked_length() var planks_count: int = floor(path_lenght / distance_between_planks) var multimesh: MultiMesh = $MultiMeshInstance3D.multimesh multimesh.instance_count = planks_count for i in planks_count: var curve_distance: float = distance_between_planks * i var plank_position: Vector3 = curve.sample_baked(curve_distance) var plank_transform: = Transform3D(Basis(), plank_position).looking_at(curve.sample_baked(curve_distance + 0.1)) multimesh.set_instance_transform(i, plank_transform)