def setup_spectator_camera(world, vehicle): vehicle_transform = vehicle.get_transform() # Get the car's position and rotation spectator = world.get_spectator() # Access the spectator camera spectator_transform = carla.Transform( vehicle_transform.location + carla.Location(x=-6, y=0, z=2), # Offset behind and above the car vehicle_transform.rotation # Match the car's orientation ) spectator.set_transform(spectator_transform) # Update the spectator's position