[gd_scene load_steps=13 format=3 uid="uid://ds7jwp4nroohl"] [ext_resource type="Script" path="res://addons/godot_rl_agents/controller/ai_controller_3d.gd" id="1_ieobn"] [ext_resource type="Script" path="res://addons/godot_rl_agents/sync.gd" id="2_5mu43"] [sub_resource type="GDScript" id="GDScript_whb00"] script/source = "extends CharacterBody3D @onready var ai_controller_3d: AIController3D = $CollisionShape3D/AIController3D const SPEED = 5.0 const JUMP_VELOCITY = 4.5 func _physics_process(delta: float) -> void: # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta # Handle jump. #if Input.is_action_just_pressed(\"ui_accept\") and is_on_floor(): #velocity.y = JUMP_VELOCITY # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. #var input_dir := Input.get_vector(\"ui_left\", \"ui_right\", \"ui_up\", \"ui_down\") #var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() #if direction: #velocity.x = direction.x * SPEED #velocity.z = direction.z * SPEED #else: #velocity.x = move_toward(velocity.x, 0, SPEED) #velocity.z = move_toward(velocity.z, 0, SPEED) velocity.x = ai_controller_3d.move.x velocity.y =ai_controller_3d.move.y move_and_slide() func _on_wall_body_shape_entered(body_rid: RID, body: Node3D, body_shape_index: int, local_shape_index: int) -> void: position = Vector3(0,0,0) func _on_area_3d_body_shape_entered(body_rid: RID, body: Node3D, body_shape_index: int, local_shape_index: int) -> void: position = Vector3(0,0,0) " [sub_resource type="BoxMesh" id="BoxMesh_bi1ur"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6pjwr"] emission_enabled = true emission = Color(0.968587, 5.67943e-06, 7.70092e-07, 1) [sub_resource type="BoxShape3D" id="BoxShape3D_gbq88"] [sub_resource type="BoxMesh" id="BoxMesh_807rh"] size = Vector3(3, 1, 3) [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_4wn23"] data = PackedVector3Array(-1.5, 0.5, 1.5, 1.5, 0.5, 1.5, -1.5, -0.5, 1.5, 1.5, 0.5, 1.5, 1.5, -0.5, 1.5, -1.5, -0.5, 1.5, 1.5, 0.5, -1.5, -1.5, 0.5, -1.5, 1.5, -0.5, -1.5, -1.5, 0.5, -1.5, -1.5, -0.5, -1.5, 1.5, -0.5, -1.5, 1.5, 0.5, 1.5, 1.5, 0.5, -1.5, 1.5, -0.5, 1.5, 1.5, 0.5, -1.5, 1.5, -0.5, -1.5, 1.5, -0.5, 1.5, -1.5, 0.5, -1.5, -1.5, 0.5, 1.5, -1.5, -0.5, -1.5, -1.5, 0.5, 1.5, -1.5, -0.5, 1.5, -1.5, -0.5, -1.5, 1.5, 0.5, 1.5, -1.5, 0.5, 1.5, 1.5, 0.5, -1.5, -1.5, 0.5, 1.5, -1.5, 0.5, -1.5, 1.5, 0.5, -1.5, -1.5, -0.5, 1.5, 1.5, -0.5, 1.5, -1.5, -0.5, -1.5, 1.5, -0.5, 1.5, 1.5, -0.5, -1.5, -1.5, -0.5, -1.5) [sub_resource type="BoxMesh" id="BoxMesh_itm4q"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_veiig"] emission_enabled = true emission = Color(0, 0.941176, 0, 1) [sub_resource type="BoxShape3D" id="BoxShape3D_4aw30"] [sub_resource type="BoxShape3D" id="BoxShape3D_215tl"] size = Vector3(1, 0.550293, 0.35083) [node name="Node3D" type="Node3D"] [node name="CharacterBody3D" type="CharacterBody3D" parent="."] script = SubResource("GDScript_whb00") [node name="MeshInstance3D" type="MeshInstance3D" parent="CharacterBody3D"] mesh = SubResource("BoxMesh_bi1ur") surface_material_override/0 = SubResource("StandardMaterial3D_6pjwr") [node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"] shape = SubResource("BoxShape3D_gbq88") [node name="AIController3D" type="Node3D" parent="CharacterBody3D/CollisionShape3D"] script = ExtResource("1_ieobn") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] transform = Transform3D(13.2709, 0, 0, 0, 1, 0, 0, 0, 15.5356, 2.07796, -1.02167, 0.0990448) mesh = SubResource("BoxMesh_807rh") [node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"] [node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_4wn23") [node name="Area3D" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.3574, -0.106641, 15.5319) [node name="MeshInstance3D" type="MeshInstance3D" parent="Area3D"] mesh = SubResource("BoxMesh_itm4q") surface_material_override/0 = SubResource("StandardMaterial3D_veiig") [node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"] shape = SubResource("BoxShape3D_4aw30") [node name="wall" type="Area3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.3574, -0.106641, 15.5319) [node name="CollisionShape3D4" type="CollisionShape3D" parent="wall"] transform = Transform3D(-4.37114e-08, 0, 140, 0, 60, 0, -1, 0, -6.11959e-06, -9.08888, 11.7785, -38.082) shape = SubResource("BoxShape3D_215tl") [node name="CollisionShape3D3" type="CollisionShape3D" parent="wall"] transform = Transform3D(-4.37114e-08, 0, 140, 0, 60, 0, -1, 0, -6.11959e-06, -9.08888, 11.7785, 6.69207) shape = SubResource("BoxShape3D_215tl") [node name="CollisionShape3D2" type="CollisionShape3D" parent="wall"] transform = Transform3D(1, 0, 0, 0, 60, 0, 0, 0, 140, -32.314, 11.7785, -15.5899) shape = SubResource("BoxShape3D_215tl") [node name="CollisionShape3D" type="CollisionShape3D" parent="wall"] transform = Transform3D(1, 0, 0, 0, 60, 0, 0, 0, 140, 6.2538, 11.7785, -15.5899) shape = SubResource("BoxShape3D_215tl") [node name="Camera3D" type="Camera3D" parent="."] transform = Transform3D(0.999981, 0.00212398, -0.00577145, 0, 0.938467, 0.34537, 0.00614987, -0.345363, 0.938449, 4.8679, 10.2977, 33.1307) [node name="Sync" type="Node" parent="."] script = ExtResource("2_5mu43") [connection signal="body_shape_entered" from="Area3D" to="CharacterBody3D" method="_on_area_3d_body_shape_entered"] [connection signal="body_shape_entered" from="wall" to="CharacterBody3D" method="_on_wall_body_shape_entered"]