Hey all, I need some help thinking through a spline that I am trying to create. I have a car that I want to move along a spline. I know how fast the car should be moving along the spline at certain distances along it. Please refer to the image below. For example: The distance of my spline starts at “0” and ends at “1”. From distance 0 to .010 on the spline, the car needs to accelerate from 0-2682 cm/s. From distance .010 to .116 on the spline the car needs to accelerate from 2682 cm/s to 5811 cm/s. How could I accomplish making a spline with this sort of control over movement speeds? What would the blueprint need to look like? I currently have a blueprint that allows me to move objects along a spline but I can only control the duration of movement along the spline. Any help would be appreciated! Thank you!
clues
first:
use an array of structs to store the position in the spline and desired speed like this:
then do a function that gives you the desired speed based on your spline position from 0 to 1 using the get spline length your are using and so some math.
you can use this too:
make a function that you give the position in the spline and it gives you back the speed target
then use Finterp TO to accelerate from current speed to desired speed:
interp speed = acceleration. higher = faster.
you have all you need:
the length of the spline. you know 0 is the start point and 1 is the end point and how long is it.
delta seconds (time)
and target speed.
Thank you for such a detailed answer! I am going to work on this today. One more question that I have; I’ve seen some people creating splines and controlling movement along the spline within the spline BP itself. I have been controlling movement along a spline within my Pawn BP. Which BP would you recommend working within when using the method you outlined above?
Thanks!
spline can be a component in your BP (spline component)