gd: added input addon
This commit is contained in:
42
guide_examples/mouse_position_3d/camera_control.gd
Normal file
42
guide_examples/mouse_position_3d/camera_control.gd
Normal file
@ -0,0 +1,42 @@
|
||||
## GUIDE makes controlling a camera pretty easy. By using the
|
||||
## window-relative and scale modifiers we can translate mouse input
|
||||
## directly into a format suitable for rotation. GUIDE also takes
|
||||
## care of only sending yaw and pitch input when the camera toggle
|
||||
## is pressed, so we don't need to have any complex input code in
|
||||
## our camera control script.
|
||||
extends Node3D
|
||||
|
||||
@export var camera_pitch:GUIDEAction
|
||||
@export var camera_yaw:GUIDEAction
|
||||
@export var camera_toggle:GUIDEAction
|
||||
@export var camera_move:GUIDEAction
|
||||
|
||||
@export var movement_speed:float = 1
|
||||
@onready var _camera_yaw:Node3D = %CameraYaw
|
||||
@onready var _camera_pitch:SpringArm3D = %CameraPitch
|
||||
|
||||
func _ready():
|
||||
camera_toggle.triggered.connect(_hide_mouse)
|
||||
camera_toggle.completed.connect(_show_mouse)
|
||||
camera_yaw.triggered.connect(_yaw)
|
||||
camera_pitch.triggered.connect(_pitch)
|
||||
|
||||
func _hide_mouse():
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
func _show_mouse():
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
func _yaw():
|
||||
_camera_yaw.rotate_y(camera_yaw.value_axis_1d)
|
||||
|
||||
func _pitch():
|
||||
_camera_pitch.rotate_x(camera_pitch.value_axis_1d)
|
||||
_camera_pitch.rotation_degrees.x = clamp(_camera_pitch.rotation_degrees.x, -75.0, 0.0)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
# we already used the input-swizzle modifier to get forward as -z, backward as z
|
||||
# left as -x and right as x, so we can use this immediately
|
||||
position += basis * camera_move.value_axis_3d * movement_speed * delta
|
||||
|
1
guide_examples/mouse_position_3d/camera_control.gd.uid
Normal file
1
guide_examples/mouse_position_3d/camera_control.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://c560cjrqx328f
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://ceti1avx1l1qw"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_ehoni"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ehoni")
|
||||
name = &""
|
||||
action_value_type = 3
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://bago2pmgvpepb"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_uluq2"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_uluq2")
|
||||
name = &""
|
||||
action_value_type = 1
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://cpljlaavuq515"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_gal8q"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_gal8q")
|
||||
name = &""
|
||||
action_value_type = 0
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://bltmi1lr7umq0"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_273ub"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_273ub")
|
||||
name = &""
|
||||
action_value_type = 1
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://2b0ncq7ogvv0"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_3to1y"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_3to1y")
|
||||
name = &""
|
||||
action_value_type = 3
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://b2jb27062t2mh"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_nysth"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_nysth")
|
||||
name = &""
|
||||
action_value_type = 0
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,270 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=59 format=3 uid="uid://bpatu7vi2kj4l"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://bltmi1lr7umq0" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_yaw.tres" id="1_8aom2"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="1_rde8c"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_mouse_position.gd" id="2_nomn0"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_mouse_axis_1d.gd" id="2_qlocd"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_window_relative.gd" id="3_p61vs"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_3d_coordinates.gd" id="3_uds3g"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="4_6a0qh"]
|
||||
[ext_resource type="Resource" uid="uid://cpljlaavuq515" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_toggle.tres" id="4_jyoym"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_negate.gd" id="4_mho8x"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="5_4hkur"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_scale.gd" id="5_b42iu"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_chorded_action.gd" id="5_qvvu8"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_mouse_button.gd" id="7_7w5i6"]
|
||||
[ext_resource type="Resource" uid="uid://bago2pmgvpepb" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_pitch.tres" id="7_swef3"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_pressed.gd" id="8_5glyu"]
|
||||
[ext_resource type="Resource" uid="uid://2b0ncq7ogvv0" path="res://guide_examples/mouse_position_3d/mapping_context/actions/cursor_3d.tres" id="9_rxgkr"]
|
||||
[ext_resource type="Resource" uid="uid://ceti1avx1l1qw" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_move.tres" id="12_v8r8p"]
|
||||
[ext_resource type="Resource" uid="uid://b2jb27062t2mh" path="res://guide_examples/mouse_position_3d/mapping_context/actions/select.tres" id="12_wmpes"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_key.gd" id="13_x2lbs"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_input_swizzle.gd" id="14_2r6td"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_46a3k"]
|
||||
script = ExtResource("2_qlocd")
|
||||
axis = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0uhrt"]
|
||||
script = ExtResource("3_p61vs")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_eipue"]
|
||||
script = ExtResource("4_mho8x")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_66vbo"]
|
||||
script = ExtResource("5_b42iu")
|
||||
scale = Vector3(6.28, 1, 1)
|
||||
apply_delta_time = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_wvbgw"]
|
||||
script = ExtResource("5_qvvu8")
|
||||
action = ExtResource("4_jyoym")
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_aqfvw"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_46a3k")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_0uhrt"), SubResource("Resource_eipue"), SubResource("Resource_66vbo")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_wvbgw")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_g62j8"]
|
||||
script = ExtResource("5_4hkur")
|
||||
action = ExtResource("1_8aom2")
|
||||
input_mappings = Array[ExtResource("4_6a0qh")]([SubResource("Resource_aqfvw")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jyaeo"]
|
||||
script = ExtResource("2_qlocd")
|
||||
axis = 1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_lo1xm"]
|
||||
script = ExtResource("3_p61vs")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_f41et"]
|
||||
script = ExtResource("4_mho8x")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_os02k"]
|
||||
script = ExtResource("5_b42iu")
|
||||
scale = Vector3(6.28, 1, 1)
|
||||
apply_delta_time = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_t4dub"]
|
||||
script = ExtResource("5_qvvu8")
|
||||
action = ExtResource("4_jyoym")
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jsmry"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_jyaeo")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_lo1xm"), SubResource("Resource_f41et"), SubResource("Resource_os02k")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_t4dub")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_4sqcw"]
|
||||
script = ExtResource("5_4hkur")
|
||||
action = ExtResource("7_swef3")
|
||||
input_mappings = Array[ExtResource("4_6a0qh")]([SubResource("Resource_jsmry")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ki4s5"]
|
||||
script = ExtResource("7_7w5i6")
|
||||
button = 2
|
||||
|
||||
[sub_resource type="Resource" id="Resource_djtqh"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_ki4s5")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_nyq6u"]
|
||||
script = ExtResource("5_4hkur")
|
||||
action = ExtResource("4_jyoym")
|
||||
input_mappings = Array[ExtResource("4_6a0qh")]([SubResource("Resource_djtqh")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_20kay"]
|
||||
script = ExtResource("13_x2lbs")
|
||||
key = 87
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0syad"]
|
||||
script = ExtResource("14_2r6td")
|
||||
order = 1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0bn66"]
|
||||
script = ExtResource("4_mho8x")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7gp34"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_20kay")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_0syad"), SubResource("Resource_0bn66")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_v2uh1"]
|
||||
script = ExtResource("13_x2lbs")
|
||||
key = 83
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_axfl8"]
|
||||
script = ExtResource("14_2r6td")
|
||||
order = 1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vij8n"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_v2uh1")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_axfl8")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rauax"]
|
||||
script = ExtResource("13_x2lbs")
|
||||
key = 65
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8xh6c"]
|
||||
script = ExtResource("4_mho8x")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8urnd"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_rauax")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_8xh6c")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_utvoa"]
|
||||
script = ExtResource("13_x2lbs")
|
||||
key = 68
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_tj7qw"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_utvoa")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_mlu0g"]
|
||||
script = ExtResource("5_4hkur")
|
||||
action = ExtResource("12_v8r8p")
|
||||
input_mappings = Array[ExtResource("4_6a0qh")]([SubResource("Resource_7gp34"), SubResource("Resource_vij8n"), SubResource("Resource_8urnd"), SubResource("Resource_tj7qw")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_hh3gq"]
|
||||
script = ExtResource("2_nomn0")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_nkih0"]
|
||||
script = ExtResource("3_uds3g")
|
||||
max_depth = 1000.0
|
||||
collide_with_areas = false
|
||||
collision_mask = 1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_wvei4"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_hh3gq")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_nkih0")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6b6vt"]
|
||||
script = ExtResource("5_4hkur")
|
||||
action = ExtResource("9_rxgkr")
|
||||
input_mappings = Array[ExtResource("4_6a0qh")]([SubResource("Resource_wvei4")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_lawue"]
|
||||
script = ExtResource("7_7w5i6")
|
||||
button = 1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_tvue7"]
|
||||
script = ExtResource("8_5glyu")
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_m30sl"]
|
||||
script = ExtResource("4_6a0qh")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_lawue")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_tvue7")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8y4cb"]
|
||||
script = ExtResource("5_4hkur")
|
||||
action = ExtResource("12_wmpes")
|
||||
input_mappings = Array[ExtResource("4_6a0qh")]([SubResource("Resource_m30sl")])
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_rde8c")
|
||||
display_name = ""
|
||||
mappings = Array[ExtResource("5_4hkur")]([SubResource("Resource_g62j8"), SubResource("Resource_4sqcw"), SubResource("Resource_nyq6u"), SubResource("Resource_mlu0g"), SubResource("Resource_6b6vt"), SubResource("Resource_8y4cb")])
|
128
guide_examples/mouse_position_3d/mou4D8E.tmp
Normal file
128
guide_examples/mouse_position_3d/mou4D8E.tmp
Normal file
@ -0,0 +1,128 @@
|
||||
[gd_scene load_steps=21 format=3 uid="uid://dmpv0dh2nk5j"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/mouse_position_3d.gd" id="1_8oqik"]
|
||||
[ext_resource type="Resource" uid="uid://bpatu7vi2kj4l" path="res://guide_examples/mouse_position_3d/mapping_context/mouse_position_3d.tres" id="2_bb21n"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/camera_control.gd" id="3_4etic"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="3_m2gj2"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/mouse_indicator.gd" id="3_tunsg"]
|
||||
[ext_resource type="Resource" uid="uid://2b0ncq7ogvv0" path="res://guide_examples/mouse_position_3d/mapping_context/actions/cursor_3d.tres" id="4_dla1l"]
|
||||
[ext_resource type="Resource" uid="uid://bago2pmgvpepb" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_pitch.tres" id="4_xr1vq"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/player.gd" id="5_8nflt"]
|
||||
[ext_resource type="Resource" uid="uid://bltmi1lr7umq0" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_yaw.tres" id="5_mnyiu"]
|
||||
[ext_resource type="Resource" uid="uid://cpljlaavuq515" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_toggle.tres" id="6_51csy"]
|
||||
[ext_resource type="Theme" uid="uid://dot0gi1yoqmrl" path="res://guide_examples/shared/ui_theme.tres" id="6_lyxvk"]
|
||||
[ext_resource type="Resource" uid="uid://b2jb27062t2mh" path="res://guide_examples/mouse_position_3d/mapping_context/actions/select.tres" id="6_uviri"]
|
||||
[ext_resource type="Resource" uid="uid://ceti1avx1l1qw" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_move.tres" id="7_1vbs8"]
|
||||
|
||||
[sub_resource type="NavigationMesh" id="NavigationMesh_sfop5"]
|
||||
vertices = PackedVector3Array(2.25, 2.656, -7, 2.25, 2.656, -3.5, 4.25, 1.156, -3.5, 4.25, 1.156, -7, 4.25, 1.156, -7, 4.25, 1.156, -3.5, 4.75, 0.905995, -2.5, 9, 0.905995, -2.5, 9, 0.905995, -9, 4.75, 0.905995, -8.5, 9, 0.905995, -9, 4.25, 0.905995, -9, 4.75, 0.905995, -8.5, -3.5, 3.656, -3.5, 2.25, 2.656, -3.5, 2.25, 2.656, -7, -7.5, 3.656, -7, 0.8125, 3.656, -3.5, 0.857143, 3.656, -7, -7.5, 3.656, 5.25, -4.25, 3.656, 5.25, -4.25, 3.656, -2.75, -7.5, 3.656, -7, -4.25, 3.656, -2.75, -3.5, 3.656, -3.5, -7.5, 3.656, -7, 9, 0.905995, -2.5, 4.75, 0.905995, -2.5, 4.25, 0.905995, -1.5, -3, 0.905995, 7.25, -9, 0.905995, 7, -9, 0.905995, 9, 9, 0.905995, 9, 4.25, 0.905995, -1.5, -2.25, 0.905995, -1.5, -2.25, 0.905995, 6.5, 9, 0.905995, 9, 9, 0.905995, -2.5, 4.25, 0.905995, -1.5, -2.25, 0.905995, 6.5, -2.25, 0.905995, 6.5, -3, 0.905995, 7.25, 9, 0.905995, 9)
|
||||
polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1), PackedInt32Array(5, 4, 6), PackedInt32Array(6, 4, 9), PackedInt32Array(6, 9, 7), PackedInt32Array(7, 9, 8), PackedInt32Array(10, 12, 11), PackedInt32Array(15, 14, 18), PackedInt32Array(18, 14, 17), PackedInt32Array(18, 17, 13), PackedInt32Array(18, 13, 16), PackedInt32Array(20, 19, 21), PackedInt32Array(21, 19, 22), PackedInt32Array(25, 24, 23), PackedInt32Array(28, 27, 26), PackedInt32Array(30, 29, 31), PackedInt32Array(31, 29, 32), PackedInt32Array(35, 34, 33), PackedInt32Array(37, 36, 38), PackedInt32Array(38, 36, 39), PackedInt32Array(42, 41, 40)]
|
||||
agent_radius = 1.0
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_taqbr"]
|
||||
|
||||
[sub_resource type="Sky" id="Sky_qlesy"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_taqbr")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_wd3mo"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_qlesy")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_q83ll"]
|
||||
transparency = 1
|
||||
albedo_color = Color(0.890196, 0.176471, 0.133333, 0.678431)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ubo0r"]
|
||||
albedo_color = Color(1.15514e-06, 0.522721, 0.747218, 1)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_3a636"]
|
||||
radius = 0.6
|
||||
height = 2.3
|
||||
|
||||
[node name="MousePosition3d" type="Node3D"]
|
||||
script = ExtResource("1_8oqik")
|
||||
mapping_context = ExtResource("2_bb21n")
|
||||
|
||||
[node name="CameraYaw" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(0.435231, 0, 0.900319, 0, 1, 0, -0.900319, 0, 0.435231, 6.62904, 4.72731, 0)
|
||||
script = ExtResource("3_4etic")
|
||||
camera_pitch = ExtResource("4_xr1vq")
|
||||
camera_yaw = ExtResource("5_mnyiu")
|
||||
camera_toggle = ExtResource("6_51csy")
|
||||
camera_move = ExtResource("7_1vbs8")
|
||||
movement_speed = 8.0
|
||||
|
||||
[node name="CameraPitch" type="SpringArm3D" parent="CameraYaw"]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 0.984808, 0.173648, 0, -0.173648, 0.984808, 0, 0, 0)
|
||||
spring_length = 8.0
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="CameraYaw/CameraPitch"]
|
||||
|
||||
[node name="World" type="Node3D" parent="."]
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="World"]
|
||||
navigation_mesh = SubResource("NavigationMesh_sfop5")
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
use_collision = true
|
||||
size = Vector3(20, 1, 20)
|
||||
|
||||
[node name="CSGBox3D2" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
transform = Transform3D(0.80368, 0.595061, 0, -0.595061, 0.80368, 0, 0, 0, 1, 2.07477, 0.832275, -5.22408)
|
||||
use_collision = true
|
||||
size = Vector3(5.14954, 2.2251, 5.07178)
|
||||
|
||||
[node name="CSGBox3D3" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.8367, 2.1428, -5.22408)
|
||||
use_collision = true
|
||||
size = Vector3(9.01666, 2.2251, 5.07178)
|
||||
|
||||
[node name="CSGBox3D4" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -5.81752, 2.1428, 1.66142)
|
||||
use_collision = true
|
||||
size = Vector3(9.01666, 2.2251, 5.07178)
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="World"]
|
||||
environment = SubResource("Environment_wd3mo")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="World"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.780496, 0.625161, 0, -0.625161, 0.780496, 0, 4.93937, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="MouseIndicator" type="CSGSphere3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84397, 1.04571, 0)
|
||||
material = SubResource("StandardMaterial3D_q83ll")
|
||||
script = ExtResource("3_tunsg")
|
||||
cursor = ExtResource("4_dla1l")
|
||||
camera_toggle = ExtResource("6_51csy")
|
||||
|
||||
[node name="CharacterBody3D" type="CharacterBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.26495, 0)
|
||||
collision_layer = 2
|
||||
input_ray_pickable = false
|
||||
floor_constant_speed = true
|
||||
script = ExtResource("5_8nflt")
|
||||
select = ExtResource("6_uviri")
|
||||
cursor = ExtResource("4_dla1l")
|
||||
|
||||
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.28249, 0)
|
||||
material = SubResource("StandardMaterial3D_ubo0r")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.26098, 0)
|
||||
shape = SubResource("CapsuleShape3D_3a636")
|
||||
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="CharacterBody3D"]
|
||||
unique_name_in_owner = true
|
||||
debug_enabled = true
|
||||
debug_use_custom = true
|
||||
debug_path_custom_color = Color(0.886095, 0.359614, 0.933159, 1)
|
||||
debug_path_custom_point_size = 7.17
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="GuideDebugger" parent="CanvasLayer" instance=ExtResource("3_m2gj2")]
|
||||
theme = ExtResource("6_lyxvk")
|
13
guide_examples/mouse_position_3d/mouse_indicator.gd
Normal file
13
guide_examples/mouse_position_3d/mouse_indicator.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends CSGSphere3D
|
||||
|
||||
@export var cursor:GUIDEAction
|
||||
@export var camera_toggle:GUIDEAction
|
||||
|
||||
func _process(delta):
|
||||
var new_pos = cursor.value_axis_3d
|
||||
if not new_pos.is_finite() or camera_toggle.is_triggered():
|
||||
visible = false
|
||||
return
|
||||
|
||||
visible = true
|
||||
global_position = new_pos
|
1
guide_examples/mouse_position_3d/mouse_indicator.gd.uid
Normal file
1
guide_examples/mouse_position_3d/mouse_indicator.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://mj7s4e2n6fpm
|
7
guide_examples/mouse_position_3d/mouse_position_3d.gd
Normal file
7
guide_examples/mouse_position_3d/mouse_position_3d.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
@export var mapping_context:GUIDEMappingContext
|
||||
|
||||
func _ready():
|
||||
GUIDE.enable_mapping_context(mapping_context)
|
@ -0,0 +1 @@
|
||||
uid://5x7dcnegcvlb
|
148
guide_examples/mouse_position_3d/mouse_position_3d.tscn
Normal file
148
guide_examples/mouse_position_3d/mouse_position_3d.tscn
Normal file
@ -0,0 +1,148 @@
|
||||
[gd_scene load_steps=22 format=3 uid="uid://dmpv0dh2nk5j"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/mouse_position_3d.gd" id="1_8oqik"]
|
||||
[ext_resource type="Resource" uid="uid://bpatu7vi2kj4l" path="res://guide_examples/mouse_position_3d/mapping_context/mouse_position_3d.tres" id="2_bb21n"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/camera_control.gd" id="3_4etic"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="3_m2gj2"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/mouse_indicator.gd" id="3_tunsg"]
|
||||
[ext_resource type="Resource" uid="uid://2b0ncq7ogvv0" path="res://guide_examples/mouse_position_3d/mapping_context/actions/cursor_3d.tres" id="4_dla1l"]
|
||||
[ext_resource type="Resource" uid="uid://bago2pmgvpepb" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_pitch.tres" id="4_xr1vq"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_3d/player.gd" id="5_8nflt"]
|
||||
[ext_resource type="Resource" uid="uid://bltmi1lr7umq0" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_yaw.tres" id="5_mnyiu"]
|
||||
[ext_resource type="Resource" uid="uid://cpljlaavuq515" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_toggle.tres" id="6_51csy"]
|
||||
[ext_resource type="Theme" uid="uid://dot0gi1yoqmrl" path="res://guide_examples/shared/ui_theme.tres" id="6_lyxvk"]
|
||||
[ext_resource type="Resource" uid="uid://b2jb27062t2mh" path="res://guide_examples/mouse_position_3d/mapping_context/actions/select.tres" id="6_uviri"]
|
||||
[ext_resource type="Resource" uid="uid://ceti1avx1l1qw" path="res://guide_examples/mouse_position_3d/mapping_context/actions/camera_move.tres" id="7_1vbs8"]
|
||||
[ext_resource type="Script" path="res://guide_examples/shared/instructions_label.gd" id="12_c4bk3"]
|
||||
|
||||
[sub_resource type="NavigationMesh" id="NavigationMesh_sfop5"]
|
||||
vertices = PackedVector3Array(2.25, 2.656, -7, 2.25, 2.656, -3.5, 4.25, 1.156, -3.5, 4.25, 1.156, -7, 4.25, 1.156, -7, 4.25, 1.156, -3.5, 4.75, 0.905995, -2.5, 9, 0.905995, -2.5, 9, 0.905995, -9, 4.75, 0.905995, -8.5, 9, 0.905995, -9, 4.25, 0.905995, -9, 4.75, 0.905995, -8.5, -3.5, 3.656, -3.5, 2.25, 2.656, -3.5, 2.25, 2.656, -7, -7.5, 3.656, -7, 0.8125, 3.656, -3.5, 0.857143, 3.656, -7, -7.5, 3.656, 5.25, -4.25, 3.656, 5.25, -4.25, 3.656, -2.75, -7.5, 3.656, -7, -4.25, 3.656, -2.75, -3.5, 3.656, -3.5, -7.5, 3.656, -7, 9, 0.905995, -2.5, 4.75, 0.905995, -2.5, 4.25, 0.905995, -1.5, -3, 0.905995, 7.25, -9, 0.905995, 7, -9, 0.905995, 9, 9, 0.905995, 9, 4.25, 0.905995, -1.5, -2.25, 0.905995, -1.5, -2.25, 0.905995, 6.5, 9, 0.905995, 9, 9, 0.905995, -2.5, 4.25, 0.905995, -1.5, -2.25, 0.905995, 6.5, -2.25, 0.905995, 6.5, -3, 0.905995, 7.25, 9, 0.905995, 9)
|
||||
polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1), PackedInt32Array(5, 4, 6), PackedInt32Array(6, 4, 9), PackedInt32Array(6, 9, 7), PackedInt32Array(7, 9, 8), PackedInt32Array(10, 12, 11), PackedInt32Array(15, 14, 18), PackedInt32Array(18, 14, 17), PackedInt32Array(18, 17, 13), PackedInt32Array(18, 13, 16), PackedInt32Array(20, 19, 21), PackedInt32Array(21, 19, 22), PackedInt32Array(25, 24, 23), PackedInt32Array(28, 27, 26), PackedInt32Array(30, 29, 31), PackedInt32Array(31, 29, 32), PackedInt32Array(35, 34, 33), PackedInt32Array(37, 36, 38), PackedInt32Array(38, 36, 39), PackedInt32Array(42, 41, 40)]
|
||||
agent_radius = 1.0
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_taqbr"]
|
||||
|
||||
[sub_resource type="Sky" id="Sky_qlesy"]
|
||||
sky_material = SubResource("ProceduralSkyMaterial_taqbr")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_wd3mo"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_qlesy")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_q83ll"]
|
||||
transparency = 1
|
||||
albedo_color = Color(0.890196, 0.176471, 0.133333, 0.678431)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ubo0r"]
|
||||
albedo_color = Color(1.15514e-06, 0.522721, 0.747218, 1)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_3a636"]
|
||||
radius = 0.6
|
||||
height = 2.3
|
||||
|
||||
[node name="MousePosition3d" type="Node3D"]
|
||||
script = ExtResource("1_8oqik")
|
||||
mapping_context = ExtResource("2_bb21n")
|
||||
|
||||
[node name="CameraYaw" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(0.435231, 0, 0.900319, 0, 1, 0, -0.900319, 0, 0.435231, 6.62904, 4.72731, 0)
|
||||
script = ExtResource("3_4etic")
|
||||
camera_pitch = ExtResource("4_xr1vq")
|
||||
camera_yaw = ExtResource("5_mnyiu")
|
||||
camera_toggle = ExtResource("6_51csy")
|
||||
camera_move = ExtResource("7_1vbs8")
|
||||
movement_speed = 8.0
|
||||
|
||||
[node name="CameraPitch" type="SpringArm3D" parent="CameraYaw"]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 0.984808, 0.173648, 0, -0.173648, 0.984808, 0, 0, 0)
|
||||
spring_length = 8.0
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="CameraYaw/CameraPitch"]
|
||||
|
||||
[node name="World" type="Node3D" parent="."]
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="World"]
|
||||
navigation_mesh = SubResource("NavigationMesh_sfop5")
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
use_collision = true
|
||||
size = Vector3(20, 1, 20)
|
||||
|
||||
[node name="CSGBox3D2" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
transform = Transform3D(0.80368, 0.595061, 0, -0.595061, 0.80368, 0, 0, 0, 1, 2.07477, 0.832275, -5.22408)
|
||||
use_collision = true
|
||||
size = Vector3(5.14954, 2.2251, 5.07178)
|
||||
|
||||
[node name="CSGBox3D3" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.8367, 2.1428, -5.22408)
|
||||
use_collision = true
|
||||
size = Vector3(9.01666, 2.2251, 5.07178)
|
||||
|
||||
[node name="CSGBox3D4" type="CSGBox3D" parent="World/NavigationRegion3D"]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -5.81752, 2.1428, 1.66142)
|
||||
use_collision = true
|
||||
size = Vector3(9.01666, 2.2251, 5.07178)
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="World"]
|
||||
environment = SubResource("Environment_wd3mo")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="World"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.780496, 0.625161, 0, -0.625161, 0.780496, 0, 4.93937, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="MouseIndicator" type="CSGSphere3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.84397, 1.04571, 0)
|
||||
material = SubResource("StandardMaterial3D_q83ll")
|
||||
script = ExtResource("3_tunsg")
|
||||
cursor = ExtResource("4_dla1l")
|
||||
camera_toggle = ExtResource("6_51csy")
|
||||
|
||||
[node name="CharacterBody3D" type="CharacterBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.26495, 0)
|
||||
collision_layer = 2
|
||||
input_ray_pickable = false
|
||||
floor_constant_speed = true
|
||||
script = ExtResource("5_8nflt")
|
||||
select = ExtResource("6_uviri")
|
||||
cursor = ExtResource("4_dla1l")
|
||||
|
||||
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.28249, 0)
|
||||
material = SubResource("StandardMaterial3D_ubo0r")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.26098, 0)
|
||||
shape = SubResource("CapsuleShape3D_3a636")
|
||||
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="CharacterBody3D"]
|
||||
unique_name_in_owner = true
|
||||
debug_enabled = true
|
||||
debug_use_custom = true
|
||||
debug_path_custom_color = Color(0.886095, 0.359614, 0.933159, 1)
|
||||
debug_path_custom_point_size = 7.17
|
||||
|
||||
[node name="UILayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="UILayer"]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -104.0
|
||||
offset_top = 56.0
|
||||
offset_right = -64.0
|
||||
offset_bottom = 96.0
|
||||
grow_horizontal = 0
|
||||
theme = ExtResource("6_lyxvk")
|
||||
script = ExtResource("12_c4bk3")
|
||||
instructions_text = "%s to send the agent somewhere.
|
||||
%s to move the camera.
|
||||
%s to rotate the camera.
|
||||
%s to tilt the camera."
|
||||
actions = Array[Resource("res://addons/guide/guide_action.gd")]([ExtResource("6_uviri"), ExtResource("7_1vbs8"), ExtResource("5_mnyiu"), ExtResource("4_xr1vq")])
|
||||
|
||||
[node name="DebuggerLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="GuideDebugger" parent="DebuggerLayer" instance=ExtResource("3_m2gj2")]
|
||||
theme = ExtResource("6_lyxvk")
|
30
guide_examples/mouse_position_3d/player.gd
Normal file
30
guide_examples/mouse_position_3d/player.gd
Normal file
@ -0,0 +1,30 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
@export var select:GUIDEAction
|
||||
@export var cursor:GUIDEAction
|
||||
@export var speed:float = 5.0
|
||||
|
||||
@onready var _navigation_agent_3d:NavigationAgent3D = %NavigationAgent3D
|
||||
|
||||
func _ready():
|
||||
select.triggered.connect(_new_destination)
|
||||
|
||||
func _physics_process(delta):
|
||||
if not _navigation_agent_3d.is_navigation_finished():
|
||||
var next_pos = _navigation_agent_3d.get_next_path_position()
|
||||
velocity = global_position.direction_to(next_pos) * speed
|
||||
else:
|
||||
velocity = Vector3.ZERO
|
||||
|
||||
if not is_on_floor():
|
||||
velocity.y = -9.18
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func _new_destination():
|
||||
var destination = cursor.value_axis_3d
|
||||
if not destination.is_finite():
|
||||
return
|
||||
_navigation_agent_3d.target_position = destination
|
||||
|
||||
|
1
guide_examples/mouse_position_3d/player.gd.uid
Normal file
1
guide_examples/mouse_position_3d/player.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://kp2vh24w5jih
|
Reference in New Issue
Block a user