# Tests for res://scripts/player.gd (minimal tree: CharacterBody3D + NavigationAgent3D). extends GdUnitTestSuite func _make_player() -> CharacterBody3D: var body := CharacterBody3D.new() var nav := NavigationAgent3D.new() nav.name = "NavigationAgent3D" body.add_child(nav) body.set_script(load("res://scripts/player.gd")) auto_free(body) add_child(body) return body func test_snap_to_server_resets_goal_position_and_velocity() -> void: var p := _make_player() var target := Vector3(1.0, 0.9, -2.0) p.snap_to_server(target) assert_that(p.global_position).is_equal(target) assert_that(p.velocity).is_equal(Vector3.ZERO) assert_that(p.get("_has_walk_goal")).is_false() func test_set_authoritative_nav_goal_sets_goal_and_target() -> void: var p := _make_player() var goal := Vector3(10.0, 0.0, 3.0) p.set_authoritative_nav_goal(goal) assert_that(p.get("_has_walk_goal")).is_true() assert_that(p.get("_auth_walk_goal")).is_equal(goal) var nav: NavigationAgent3D = p.get_node("NavigationAgent3D") as NavigationAgent3D assert_that(nav.target_position).is_equal(goal) func test_clear_nav_goal_clears_velocity_and_nav_target() -> void: var p := _make_player() p.velocity = Vector3(1.0, 0.0, 0.0) p.set_authoritative_nav_goal(Vector3(5.0, 0.0, 5.0)) p.clear_nav_goal() assert_that(p.velocity).is_equal(Vector3.ZERO) assert_that(p.get("_has_walk_goal")).is_false() var nav: NavigationAgent3D = p.get_node("NavigationAgent3D") as NavigationAgent3D assert_that(nav.target_position).is_equal(p.global_position)