- Home /
The player's car following a certain path
Can someone help me (i a new guy to coding).. i want to write a code in Javascript to make the player,s car follow a certian path made by game objects.. if I enter the first game object the next one should spawn to show you the next way to go.. (like arrows on the road the show the path). the the first game object has to dissappear.
Answer by CodeMasterMike · Nov 08, 2012 at 12:08 PM
You don't mention how you want to do this (with physics etc), and there are different ways to do something like this varying from very simple to very complicated. So below is a very simple example on how you can do it.
I don't have code to show, but you can follow these steps, and learn something on the way:
Get the position from the game object you want to move towards.
Interpolate (for instance, use the function Lerp) the car position with your orginal start position, and the position you retrieved from the game object you want to drive towards. (See step 1.)
Use Look At to rotate the car (the car will "look" in that direction) towards the position you want to reach.
When you have reached your position (or whenever you wish) spawn a new object at its proper place and repeat step 1 and 3.
This is a very simple example of how you can do it.
Your answer
Follow this Question
Related Questions
Follow a dynamic path? 0 Answers
Changing Target Depending On Car Selected 1 Answer
Steering an AI vehicle to a waypoint using float of -1 to 1? 1 Answer
How to make one game object follow another? 1 Answer
Object following the path 3 Answers