Im building a racing game, and i want to make a minimap of the track with only 2 operations on it, goForward and goBack, making the car go forward on the minimap and backwards, to keep the track of the car position on the minimap.
But how can i keep track of the cars this way, like in mario kart.
I tought about using trigger and map the trigger positions into the minimap, but i dont think it would accurate unless i placed a few hundreds of them
I don’t know for sure how it’s done in games such as Mario Kart, but I would imagine that the track is represented using a spline of some sort. The idea would then be to find the closest point on the spline to the vehicle’s position, compute the corresponding parametric value for that point, and then determine the vehicle’s place (and position on the minimap track) accordingly.
This isn’t exactly trivial, but you might be able to get ‘close enough’ using a piecewise linear approximation for the spline. (Or maybe someone else will have a better suggestion.)
Thank you for the idea, i’ll try to work with this . Tought its gonna be a pain to evaluate the points from the spline
but any (simpler) other idea is welcome too , lol.
Gonna update if i get something here.
Does that tutorial address the question of how to keep track of placing and show where each car is with respect to the track? (I think that’s what the OP was asking.)
Or you could use a 2nd top down view camera, rendering the track and the cars only.
EDIT: If you don’t want to render the cars twice, you could attach a plane with a simple car texture on top of the car GO and render this plane only inside the Mini-Map.
Might not be the coolest solution, but worked at least for me .
thanks for the post, but i’m looking for a different feel on the minimap, and the camera rendering won’t fill my needs
i need to track the car’s position on a texture, exactly like mario kart and some other racing games.
You can use a top-down orthogonal camera just to get the transformed positions of objects and then use wathever rendering metod you want to show the data.
To be more precise, you put a orthographic camera on top of your car pointing down then, for each car in the view frustum, you call camera.WorldToViewportPoint (car.transform.position); to get the position of the car on the camera viewport. That is your minimap coordinate. Then you can render a point or an icon at this coordinate.
If you want your minimap to always face north you just block rotation of the camera on y axys.
Changing camera size will change the area of the minimap.
You can track all objects you want this way of course.