import unreal as u,json,time,math,traceback from pathlib import Path ROOT=Path(__file__).resolve().parents[3];LEVEL=u.get_editor_subsystem(u.LevelEditorSubsystem);EDITOR=u.get_editor_subsystem(u.UnrealEditorSubsystem);report={'floor_traces':{},'movement':None};u.EditorPythonScripting.set_keep_python_script_alive(True) state={'start':time.monotonic(),'phase':'load','t':0,'positions':[]} def pos(v):return u.Vector(v[0]*100,-v[1]*100,v[2]*100) def tick(dt): try: elapsed=time.monotonic()-state['start'] if state['phase']=='finish': if time.monotonic()-state['t']>3: u.unregister_slate_post_tick_callback(handle);u.log('HOMESTEAD_WALK_VERIFIED '+json.dumps(report['movement']));u.SystemLibrary.quit_editor() return if elapsed>90:raise RuntimeError('Play-in-editor movement test timed out') if state['phase']=='load': if elapsed<12:return u.AutomationLibrary.finish_loading_before_screenshot();LEVEL.editor_request_begin_play();state['phase']='settle';state['t']=time.monotonic();return game=EDITOR.get_game_world() if not game:return pawn=u.GameplayStatics.get_player_pawn(game,0) if not pawn:return if state['phase']=='settle': if time.monotonic()-state['t']<4:return assert 'HomesteadWalker' in pawn.get_class().get_name(),pawn.get_class().get_name() for name,xy in [('verandah',(0,4)),('living',(-1.8,1)),('corridor',(-7.5,-1.8)),('bedroom',(-10.7,-3.5)),('meditation',(-11.8,10.8)),('garage',(2,-18)),('garden',(0,13)),('training',(-10,-19))]: result=u.SystemLibrary.line_trace_single(game,pos((*xy,2.9)),pos((*xy,-2)),u.TraceTypeQuery.TRACE_TYPE_QUERY1,True,[pawn],u.DrawDebugTrace.NONE,True);assert result is not None,name;report['floor_traces'][name]='hit' p=pawn.get_actor_location();state['initial']=[p.x,p.y,p.z];assert 1702.5: q=pawn.get_actor_location();assert 15702.5: a=state['initial'];dist=math.hypot(p.x-a[0],p.y-a[1]);assert dist>100,('No meaningful movement',dist);assert 170