- Home /
How to move a gameobject in a path but control its direction?
Hi all,
This should really be an old question, but i could not think of a way of doing this (probably thinking too much).
So i have a player and have a few tracks (like railway tracks) set on my scene, i would like the player/car to move automatically (maybe transform.translate or lerping the position) etc. But when it reaches a joint/junction/node I would like to hit Right or Left to determine which direction would it take and continue moving forward (this would be a sharp 90 degree turn). I did get this done having colliders at the joints and when it collides i would change the direction. But i find this as a novice way of doing it. Also, i would want to have enemy cars follow the same path my player/car takes. (So the enemy should turn/rotate exactly at the joints/junction where my car rotated).
Would appreciate any help. Thanks.