- Home /
witch approach for an car race curve
hello! i hope someone can help me, i'll make a simple racing game where you don't control the car directly, you just are able to turn the car when a button is pressed, ( for sure you have to press the button in a specific zone to make it turn in the right way) here is the point, i have different curve in a multiple form and before the curve there is this "brake point", i'll pasta here a simple picture that i did to make it more clear
turning point is dynamic i'll do it everything by code without any kind of rigidbody or collider, ( i have to practice with coding so that's why)
any advice to how do that?
Answer by Pakillottk · Sep 28, 2018 at 02:23 AM
If I understand correctly, you want the car to turn only if a button it's pressed when in a predefined position in the curve. The most simple solution would be making an empty object with a triggered collider. If the car it's inside the trigger and you press the button, you turn. Very straightforward.
If we consider that you manually position the turn points in the scene, the shape of the road doesn't matter, for the "turn triggering" with this method.
Now if you are refering to make the exact trajectory of the car along the path, then I suggest that you use some kind of spline curve to define the movement. $$anonymous$$aybe a Bezier Curve (https://en.wikipedia.org/wiki/B%C3%A9zier_curve).
If you use a Bezier you could use the start point of the curve as your "turn trigger" positon and then you'd shape the curve path. For the movement you'll be following a straight line until you hit a turn trigger (the start of the Bezier curve). If the turn button it's pressed you follow the curve path till the end and keep straight afterwards. Else crash the car or whatever...
Your answer
Follow this Question
Related Questions
Subdivide Bezier Curves 3 Answers
Multiple Cars not working 1 Answer
(Scripting) Getting a circle of points in an array 1 Answer