MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / _spawn_hero

Method _spawn_hero

PythonAPI/examples/no_rendering_mode.py:1008–1024  ·  view source on GitHub ↗

Spawns the hero actor when the script runs

(self)

Source from the content-addressed store, hash-verified

1006 self._spawn_hero()
1007
1008 def _spawn_hero(self):
1009 """Spawns the hero actor when the script runs"""
1010 # Get a random blueprint.
1011 blueprint = random.choice(self.world.get_blueprint_library().filter(self.args.filter))
1012 blueprint.set_attribute('role_name', 'hero')
1013 if blueprint.has_attribute('color'):
1014 color = random.choice(blueprint.get_attribute('color').recommended_values)
1015 blueprint.set_attribute('color', color)
1016 # Spawn the player.
1017 while self.hero_actor is None:
1018 spawn_points = self.world.get_map().get_spawn_points()
1019 spawn_point = random.choice(spawn_points) if spawn_points else carla.Transform()
1020 self.hero_actor = self.world.try_spawn_actor(blueprint, spawn_point)
1021 self.hero_transform = self.hero_actor.get_transform()
1022
1023 # Save it in order to destroy it when closing program
1024 self.spawned_hero = self.hero_actor
1025
1026 def tick(self, clock):
1027 """Retrieves the actors for Hero and Map modes and updates de HUD based on that"""

Callers 1

select_hero_actorMethod · 0.95

Calls 1

TransformMethod · 0.45

Tested by

no test coverage detected