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

Method select_hero_actor

PythonAPI/examples/no_rendering_mode.py:998–1006  ·  view source on GitHub ↗

Selects only one hero actor if there are more than one. If there are not any, it will spawn one.

(self)

Source from the content-addressed store, hash-verified

996 self.world.on_tick(lambda timestamp: World.on_world_tick(weak_self, timestamp))
997
998 def select_hero_actor(self):
999 """Selects only one hero actor if there are more than one. If there are not any, it will spawn one."""
1000 hero_vehicles = [actor for actor in self.world.get_actors()
1001 if 'vehicle' in actor.type_id and actor.attributes['role_name'] == 'hero']
1002 if len(hero_vehicles) > 0:
1003 self.hero_actor = random.choice(hero_vehicles)
1004 self.hero_transform = self.hero_actor.get_transform()
1005 else:
1006 self._spawn_hero()
1007
1008 def _spawn_hero(self):
1009 """Spawns the hero actor when the script runs"""

Callers 2

startMethod · 0.95
_parse_eventsMethod · 0.80

Calls 1

_spawn_heroMethod · 0.95

Tested by

no test coverage detected