sds-:
Dude is awesome, when you get a please post how you achieved it.
Will do - I’ll post the code tomorrow for everyone to play with, just got it submitted in our local code repository today. Unfortunately it requires some C++ engine changes, otherwise I’d release it as a plugin.
Our team is going to spend the next few weeks trying it out as a whiteboxing tool for rapid track prototyping/iteration on Space Dust Racing, and I’m going to extend the idea further by allowing you to specify a static mesh for every SplineMeshComponent segment on the spline. If it works as I’m hoping it will, we can create a set of 3D road tiles, then build the majority of our tracks using tool to stretch them into shape. We’ll still have custom geometry in parts for set pieces/terrain etc., but should take a lot of the pain away for the artists!
Here we go:
Source code + blueprint diagrams: (2.5MB)
is a C++ engine extension of UE4’s built-in SplineComponent and SplineComponentVisualizer, with additional support for arbitrary rotation (eg. twisting, looping) and width/scale at each spline point.
Look for the “// BEGIN SDS” and “// END SDS” markers in the C++ code to see what I’ve added.
At some point I’ll get around to cleaning up and submitting a pull request to the engine mainline, but for now here it is to play around with - get your hands dirty!
I’d recommend watching 's tutorials as you’ll want to implement a similar road spline blueprint class, replacing SplineComponent with RoadSplineComponent.
I’ve included my own blueprint class construction script for reference as a PNG in the ZIP. Use to create roads that fit along the road spline. You’ll need to set up your Tiles array with static meshes for different road tiles, and populate your Tile Indices array to specify which mesh each road segment should use.
BP_RoadSplineActor variables (and sensible defaults):
Spacing: 2000. Distance in world units along spline between each road track segment. Each segment is one SplineMeshComponent instance.
Tangent scale: 2000. Changes how the road will be deformed between spline points. Generally you always want to equal Spacing for best results.
TrackWidthScale: 0.002. Scalar to align static mesh widths with the spline width.
Create Segments: Boolean to toggle the spline meshes on/off.
Spline editing controls:
Same as SplineComponent, except the rotation + scale gizmos work.
Hold Alt to drag out a new spline point.
Scaling the X axis controls the tangent.
Scaling the Y/Z axes controls the spline width.
I really hope Epic accepts your pull request. is too good to deny. I’m also too lazy to get involved with Visual Studio to build .
Hear hear.
+1
That’s great, I was contemplating doing something like , but glad someone else did it already, hehe.
It would be cool if could be used to make a full fledged road tool that supports branching for streets and intersections. Actually I myself need a railroad tool more than roads but I guess the principles are the same…
Hi ,great work. I myself want to use splines for a movement proplem.
So i have a question about the implementation of splines:
I want to move my character while he is standing on a moving walkway like you find them in a airport.
The moving walkway should have a curved form sitting on a circle or donut.
I need to apply a force which moves the character in every second tangential to the circle the moving walkway follows.
Here comes the spline into play (at least i hope it can come into play here).
I want to place a spline in the form of the circle in, or over the moving walkway so that it follows its form exactly and want to read out the tangential vectorcomponent of the spline to apply the force of the moving walkway in each point.
From what i have watched so far you only can access the location information of the spline on each point of the spline ?
Is that true or is there also a way to get the location information of the spline also between its points ?
I need some trace blueprint which traces the spline while the character/player is moving above the spline and acceses its tangential vector very frequent to apply force in direction.
Has anyone a idea how i can do that ?
definitely sounds possible, at least with C++. I’m using a similar approach to drive our AI in Space Dust Racers.
With the inbuilt UE4 SplineComponent, you can find the closest point on a spline to any world point. See USplineComponent::SplineInfo->InaccurateFindNearest(…).
Similarly, if you specify a time or a distance along the spline component, you can get the location and forward vector at any point along the spline, not just the keys. See:
USplineComponent::GetWorldLocationAtDistanceAlongSpline()
USplineComponent::GetWorldDirectionAtDistanceAlongSpline()
USplineComponent::GetWorldLocationAtTime()
USplineComponent::GetWorldDirectionAtTime()
Hi sds-, were you still planning to (or did you already!) make a pull request for these changes? They look very cool!
Yeah, is need to be added.
Apologies for the epic late reply - I wish the forum software automatically subscribed you by email to threads you post in.
RE: making a pull request, I haven’t done yet as there are a few dependencies with other local C++ changes we’ve made so it would be a bit of an effort to clean it up and get it into mainline. Unfortunately I’ve got a pretty tight schedule for Space Dust Racers so I probably won’t have time to do any time soon. Anyone is welcome to grab the code snapshot I posted above and push it through of course - I imagine if someone from the Epic team had a look, they’d probably have their own ideas about ways the tool could be improved. My implementation is very “road”-centric.
I tried integrating with the latest Github source, but unfortunately it is not working properly. After converting FComponentInstanceDataBase to FActorComponentInstanceData I was able to get it to compile, but I am unable to edit the spline at all in the editor or the blueprint
These changes were made against 4.5 release, that’d be why.
Hey all,
I’m currently working on a large upgrade of USplineComponent, and arbitrary rotation and scale on spline points will be one of the new features, along with editing of the spline in the Blueprint Editor.
, thanks very much for your patch; although I’m unable to use it verbatim, it’s served as a useful reference and we’ll make sure you’re credited in the next engine release
I’ll update thread with progress.
[To clarify, as I’m not in general on the forums, I’m an Epic employee!]
wow nice! thank you !
I can’t remember some of the things I had wanted for blueprint splines, but if I had one blueprint wish for splines right now, it would be the ability to splice them together during runtime. End to end, end to middle, you name it.
Look forward to seeing improvements in general!
For the 4.8 will be ready ?
Im interrested in to. What about connecting multiple splines to create intersections? Anyone knows how?
Just saw , that’s awesome news Richard, thanks a lot! Apologies I couldn’t find the time to clean it up and submit a pull request for you. If you have any questions on the implementation just shout -