Hi, great template. My question might be a basic one since I am still a beginner/learning Godot. So, I got your template (which is fully functional). In my tests I changed the camera/cars/expanded track and a few other details ... but when the race is completed (like all cars pass thru the finish line and shows the podium), I was trying to change scene (with a simple button in the podium window). At that point, the game crashed referencing two lines in the if statement (in car_controller.gd) ...
if is_AI and RaceManager.is_countdown_finished:
# Calculate the direction to the target
var target_direction = (waypoints[current_waypoint].global_transform.origin - model.global_transform.origin).normalized()
# Calculate the cross product of the car's forward direction and the target direction
var cross = model.global_transform.basis[2].cross(target_direction)
So, I added a silght modification to your code ... but cannot manage to fix the issue. Here is what I did, might be helpful ...
if is_AI and RaceManager.is_countdown_finished:
# Check if the model and the current waypoint are still valid and inside the tree
if is_instance_valid(model) and model.is_inside_tree() and is_instance_valid(waypoints[current_waypoint]) and waypoints[current_waypoint].is_inside_tree():
# Calculate the direction to the target
var target_direction = (waypoints[current_waypoint].global_transform.origin - model.global_transform.origin).normalized()
# Calculate the cross product of the car's forward direction and the target direction
var cross = model.global_transform.basis[2].cross(target_direction)
Now it does change scene, but the cars from the previous race remain in the middle of the screen, and if I try to select a car for a new race ... it crashed again.
My plan was for making a restart race or go to next race ... but trying to change scene just leads to another crashed game.
Please advise,
Thanks in advance.