2

I am currently creating a top down racing game ( or trying! ) using SpriteKit. I am creating tracks procedurally with catmullrom splines created from points. I have access to three sets of points, the inside of the track, the outside of the track and the centre line of the track.

A representation of a track showing current AI path line

I am using GKAgents, GKGoals, and GKBehaviours from GameplayKit for the AI cars, and I currently have a few cars following a GKPath. The points I have provided to GKPath are the centre line shown in yellow in the image.

My maths skills are not all that! So my question is given that I know the inner, outer and centre points, how can I modify my centre line points to create a more realistic racing line for the AI cars to follow?

If you need a clearer idea of what is going on, you can see the central points in a video: https://www.youtube.com/watch?v=yhwNL0iCBuU

Jason
  • 118
  • 12
  • This is not an answer, but as a starting point look into finding the apex of each bend (i.e the inner point where the bend starts to 'unwind' and then possible the point at which the outside of each 'straight' turns in. Then use these point to form a new path. – Steve Ives Jul 28 '17 at 13:04
  • An alternative approach might be to take the outside path of each curve, find the point on this curve that is at the centre of the curve, and then generate new curves by repeatedly moving this one point towards the inner edge, until part of that curve falls outside the track. Then go back to the last curve. – Steve Ives Jul 28 '17 at 13:06
  • Thanks for your suggestion Steve, it had crossed my mind to try and discover the Apex. More googling I think. – Jason Jul 28 '17 at 13:07

0 Answers0