21 lines
612 B
Python
Executable File
21 lines
612 B
Python
Executable File
|
|
# This recipe spawns an actor and the spectator camera at the actor's location.
|
|
|
|
# ...
|
|
world = client.get_world()
|
|
spectator = world.get_spectator()
|
|
|
|
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
|
|
transform = random.choice(world.get_map().get_spawn_points())
|
|
vehicle = world.try_spawn_actor(vehicle_bp, transform)
|
|
|
|
# Wait for world to get the vehicle actor
|
|
world.tick()
|
|
|
|
world_snapshot = world.wait_for_tick()
|
|
actor_snapshot = world_snapshot.find(vehicle.id)
|
|
|
|
# Set spectator at given transform (vehicle transform)
|
|
spectator.set_transform(actor_snapshot.get_transform())
|
|
# ...
|