From e188eaff460b115a0d248017a800ddcb25aad0e5 Mon Sep 17 00:00:00 2001 From: shahriarlabib000 Date: Thu, 31 Oct 2024 13:32:19 +0600 Subject: [PATCH] Add touch screen support for 3d/platformer --- 3d/platformer/README.md | 3 + 3d/platformer/coin/coin.tscn | 2 +- 3d/platformer/enemy/enemy.tscn | 12 +- 3d/platformer/export_presets.cfg | 221 ------------------ 3d/platformer/game.tscn | 90 ++++++- 3d/platformer/player/bullet/bullet.gd | 3 + 3d/platformer/player/bullet/bullet.tscn | 5 +- 3d/platformer/player/player.gd | 8 +- 3d/platformer/player/player.tscn | 84 +++---- 3d/platformer/project.godot | 10 +- .../meshes/previews/corner_fix.webp.import | 6 +- 3d/platformer/stage/stage.tscn | 14 +- 3d/platformer/touch_screen_ui.gd | 13 ++ .../textures/joystick_base_outline.png | Bin 0 -> 4827 bytes .../textures/joystick_base_outline.png.import | 34 +++ .../textures/joystick_tip.png | Bin 0 -> 1780 bytes .../textures/joystick_tip.png.import | 34 +++ .../textures/joystick_tip_arrows.png | Bin 0 -> 2229 bytes .../textures/joystick_tip_arrows.png.import | 34 +++ .../virtual_joystick/virtual_joystick.gd | 169 ++++++++++++++ .../virtual_joystick_scene.tscn | 51 ++++ 21 files changed, 495 insertions(+), 298 deletions(-) delete mode 100644 3d/platformer/export_presets.cfg create mode 100644 3d/platformer/touch_screen_ui.gd create mode 100644 3d/platformer/virtual_joystick/textures/joystick_base_outline.png create mode 100644 3d/platformer/virtual_joystick/textures/joystick_base_outline.png.import create mode 100644 3d/platformer/virtual_joystick/textures/joystick_tip.png create mode 100644 3d/platformer/virtual_joystick/textures/joystick_tip.png.import create mode 100644 3d/platformer/virtual_joystick/textures/joystick_tip_arrows.png create mode 100644 3d/platformer/virtual_joystick/textures/joystick_tip_arrows.png.import create mode 100644 3d/platformer/virtual_joystick/virtual_joystick.gd create mode 100644 3d/platformer/virtual_joystick/virtual_joystick_scene.tscn diff --git a/3d/platformer/README.md b/3d/platformer/README.md index 7aefed8c97b..d65ec94ed7f 100644 --- a/3d/platformer/README.md +++ b/3d/platformer/README.md @@ -10,6 +10,9 @@ Renderer: Forward+ Check out this demo on the asset library: https://godotengine.org/asset-library/asset/2748 +This project uses Virtual joystick add-on by [`Marco F`](https://github.com/MarcoFazioRandom) for touch screen input. +check it out: https://godotengine.org/asset-library/asset/1787 + ## Screenshots ![Screenshot](screenshots/platformer.webp) diff --git a/3d/platformer/coin/coin.tscn b/3d/platformer/coin/coin.tscn index 7f8c03dc646..2ec84e9bb99 100644 --- a/3d/platformer/coin/coin.tscn +++ b/3d/platformer/coin/coin.tscn @@ -236,10 +236,10 @@ mesh = SubResource("QuadMesh_kqa4x") surface_material_override/0 = SubResource("StandardMaterial3D_7q0mq") [node name="Animation" type="AnimationPlayer" parent="."] -autoplay = "spin" libraries = { "": SubResource("AnimationLibrary_7v453") } +autoplay = "spin" [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00894194, 0.575859, 0.0193955) diff --git a/3d/platformer/enemy/enemy.tscn b/3d/platformer/enemy/enemy.tscn index ab32efc624e..319f857261c 100644 --- a/3d/platformer/enemy/enemy.tscn +++ b/3d/platformer/enemy/enemy.tscn @@ -437,8 +437,8 @@ axis_lock_angular_y = true axis_lock_angular_z = true physics_material_override = SubResource("1") custom_integrator = true -max_contacts_reported = 5 contact_monitor = true +max_contacts_reported = 5 script = ExtResource("1") [node name="Enemy" parent="." instance=ExtResource("2_qf8n3")] @@ -448,13 +448,13 @@ bones/1/position = Vector3(-5.04871e-28, 0.661877, 0) bones/1/rotation = Quaternion(0.707107, -2.48537e-07, -1.95408e-07, 0.707107) bones/2/position = Vector3(-3.87449e-08, 0.475726, -0.0617121) bones/3/position = Vector3(0.913587, 0.661877, 0.631826) -bones/3/rotation = Quaternion(1, 0, 7.54979e-08, -1.05879e-22) +bones/3/rotation = Quaternion(1, -2.49197e-38, 7.54979e-08, -1.05879e-22) bones/5/position = Vector3(-0.913587, 0.661877, 0.631826) -bones/5/rotation = Quaternion(1, 0, 7.54979e-08, -1.05879e-22) +bones/5/rotation = Quaternion(1, -2.49197e-38, 7.54979e-08, -1.05879e-22) bones/7/position = Vector3(1.05436, 0.661877, -0.654576) -bones/7/rotation = Quaternion(1, 0, 7.54979e-08, -1.05879e-22) +bones/7/rotation = Quaternion(1, -2.49197e-38, 7.54979e-08, -1.05879e-22) bones/9/position = Vector3(-1.05436, 0.661877, -0.654576) -bones/9/rotation = Quaternion(1, 0, 7.54979e-08, -1.05879e-22) +bones/9/rotation = Quaternion(1, -2.49197e-38, 7.54979e-08, -1.05879e-22) [node name="RayFloor" type="RayCast3D" parent="Enemy/Skeleton" index="1"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.643772, 0.803052) @@ -465,11 +465,11 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.643772, 0.310413) target_position = Vector3(0, 0, 1.5) [node name="AnimationPlayer" parent="Enemy" index="1"] -autoplay = "walk" libraries = { "": SubResource("AnimationLibrary_f4l5d"), "extra": SubResource("AnimationLibrary_q27i1") } +autoplay = "walk" [node name="Sphere1" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.74185, 0.267137) diff --git a/3d/platformer/export_presets.cfg b/3d/platformer/export_presets.cfg deleted file mode 100644 index 9573ac06e83..00000000000 --- a/3d/platformer/export_presets.cfg +++ /dev/null @@ -1,221 +0,0 @@ -[preset.0] - -exclude_filter="" -export_filter="all_resources" -include_filter="" -name="Linux/X11" -patch_list=PackedStringArray( ) -platform="Linux/X11" -runnable=true - -[preset.0.options] - -binary_format/64_bits=true -custom_template/debug="" -custom_template/release="" -texture_format/etc=false -texture_format/etc2=false -texture_format/s3tc=true - -[preset.1] - -exclude_filter="" -export_filter="all_resources" -include_filter="" -name="Android" -patch_list=PackedStringArray( ) -platform="Android" -runnable=true - -[preset.1.options] - -apk_expansion/SALT="" -apk_expansion/enable=false -apk_expansion/public_key="" -architecture/arm=true -architecture/x86=false -command_line/extra_args="" -custom_package/debug="" -custom_package/release="" -keystore/release="" -keystore/release_password="" -keystore/release_user="" -one_click_deploy/clear_previous_install=true -package/icon="" -package/name="" -package/signed=true -package/unique_name="org.godotengine.$genname" -permissions/access_checkin_properties=false -permissions/access_coarse_location=false -permissions/access_fine_location=false -permissions/access_location_extra_commands=false -permissions/access_mock_location=false -permissions/access_network_state=false -permissions/access_surface_flinger=false -permissions/access_wifi_state=false -permissions/account_manager=false -permissions/add_voicemail=false -permissions/authenticate_accounts=false -permissions/battery_stats=false -permissions/bind_accessibility_service=false -permissions/bind_appwidget=false -permissions/bind_device_admin=false -permissions/bind_input_method=false -permissions/bind_nfc_service=false -permissions/bind_notification_listener_service=false -permissions/bind_print_service=false -permissions/bind_remoteviews=false -permissions/bind_text_service=false -permissions/bind_vpn_service=false -permissions/bind_wallpaper=false -permissions/bluetooth=false -permissions/bluetooth_admin=false -permissions/bluetooth_privileged=false -permissions/brick=false -permissions/broadcast_package_removed=false -permissions/broadcast_sms=false -permissions/broadcast_sticky=false -permissions/broadcast_wap_push=false -permissions/call_phone=false -permissions/call_privileged=false -permissions/camera=false -permissions/capture_audio_output=false -permissions/capture_secure_video_output=false -permissions/capture_video_output=false -permissions/change_component_enabled_state=false -permissions/change_configuration=false -permissions/change_network_state=false -permissions/change_wifi_multicast_state=false -permissions/change_wifi_state=false -permissions/clear_app_cache=false -permissions/clear_app_user_data=false -permissions/control_location_updates=false -permissions/delete_cache_files=false -permissions/delete_packages=false -permissions/device_power=false -permissions/diagnostic=false -permissions/disable_keyguard=false -permissions/dump=false -permissions/expand_status_bar=false -permissions/factory_test=false -permissions/flashlight=false -permissions/force_back=false -permissions/get_accounts=false -permissions/get_package_size=false -permissions/get_tasks=false -permissions/get_top_activity_info=false -permissions/global_search=false -permissions/hardware_test=false -permissions/inject_events=false -permissions/install_location_provider=false -permissions/install_packages=false -permissions/install_shortcut=false -permissions/internal_system_window=false -permissions/internet=false -permissions/kill_background_processes=false -permissions/location_hardware=false -permissions/manage_accounts=false -permissions/manage_app_tokens=false -permissions/manage_documents=false -permissions/master_clear=false -permissions/media_content_control=false -permissions/modify_audio_settings=false -permissions/modify_phone_state=false -permissions/mount_format_filesystems=false -permissions/mount_unmount_filesystems=false -permissions/nfc=false -permissions/persistent_activity=false -permissions/process_outgoing_calls=false -permissions/read_calendar=false -permissions/read_call_log=false -permissions/read_contacts=false -permissions/read_external_storage=false -permissions/read_frame_buffer=false -permissions/read_history_bookmarks=false -permissions/read_input_state=false -permissions/read_logs=false -permissions/read_phone_state=false -permissions/read_profile=false -permissions/read_sms=false -permissions/read_social_stream=false -permissions/read_sync_settings=false -permissions/read_sync_stats=false -permissions/read_user_dictionary=false -permissions/reboot=false -permissions/receive_boot_completed=false -permissions/receive_mms=false -permissions/receive_sms=false -permissions/receive_wap_push=false -permissions/record_audio=false -permissions/reorder_tasks=false -permissions/restart_packages=false -permissions/send_respond_via_message=false -permissions/send_sms=false -permissions/set_activity_watcher=false -permissions/set_alarm=false -permissions/set_always_finish=false -permissions/set_animation_scale=false -permissions/set_debug_app=false -permissions/set_orientation=false -permissions/set_pointer_speed=false -permissions/set_preferred_applications=false -permissions/set_process_limit=false -permissions/set_time=false -permissions/set_time_zone=false -permissions/set_wallpaper=false -permissions/set_wallpaper_hints=false -permissions/signal_persistent_processes=false -permissions/status_bar=false -permissions/subscribed_feeds_read=false -permissions/subscribed_feeds_write=false -permissions/system_alert_window=false -permissions/transmit_ir=false -permissions/uninstall_shortcut=false -permissions/update_device_stats=false -permissions/use_credentials=false -permissions/use_sip=false -permissions/vibrate=false -permissions/wake_lock=false -permissions/write_apn_settings=false -permissions/write_calendar=false -permissions/write_call_log=false -permissions/write_contacts=false -permissions/write_external_storage=false -permissions/write_gservices=false -permissions/write_history_bookmarks=false -permissions/write_profile=false -permissions/write_secure_settings=false -permissions/write_settings=false -permissions/write_sms=false -permissions/write_social_stream=false -permissions/write_sync_settings=false -permissions/write_user_dictionary=false -screen/immersive_mode=true -screen/orientation=0 -screen/support_large=true -screen/support_normal=true -screen/support_small=true -screen/support_xlarge=true -screen/use_32_bits_view=true -user_permissions/0=false -user_permissions/1=false -user_permissions/10=false -user_permissions/11=false -user_permissions/12=false -user_permissions/13=false -user_permissions/14=false -user_permissions/15=false -user_permissions/16=false -user_permissions/17=false -user_permissions/18=false -user_permissions/19=false -user_permissions/2=false -user_permissions/3=false -user_permissions/4=false -user_permissions/5=false -user_permissions/6=false -user_permissions/7=false -user_permissions/8=false -user_permissions/9=false -version/code=1 -version/name="1.0" diff --git a/3d/platformer/game.tscn b/3d/platformer/game.tscn index 7194ee5b79c..ac536746308 100644 --- a/3d/platformer/game.tscn +++ b/3d/platformer/game.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=9 format=3 uid="uid://d0lrpf3mmjdsx"] +[gd_scene load_steps=13 format=3 uid="uid://d0lrpf3mmjdsx"] [ext_resource type="PackedScene" uid="uid://dohp772jyjxb7" path="res://stage/stage.tscn" id="1_ybvw5"] [ext_resource type="PackedScene" uid="uid://dfxo2jwbj4aeh" path="res://coin/coin.tscn" id="2_chew2"] [ext_resource type="PackedScene" uid="uid://o5q0hy6cg6nt" path="res://enemy/enemy.tscn" id="3_nhwvs"] [ext_resource type="PackedScene" uid="uid://cc4idhykjp5f5" path="res://player/player.tscn" id="4_ray4s"] +[ext_resource type="Script" path="res://touch_screen_ui.gd" id="5_7os5d"] +[ext_resource type="PackedScene" uid="uid://dmr0fcamx7t56" path="res://virtual_joystick/virtual_joystick_scene.tscn" id="5_smd4r"] [sub_resource type="PhysicsMaterial" id="1"] friction = 0.0 @@ -17,6 +19,11 @@ friction = 0.0 [sub_resource type="PhysicsMaterial" id="4"] friction = 0.0 +[sub_resource type="Theme" id="Theme_21ljx"] +CheckButton/font_sizes/font_size = 32 + +[sub_resource type="CanvasTexture" id="CanvasTexture_7o5bd"] + [node name="Game" type="Node3D"] [node name="Stage" parent="." instance=ExtResource("1_ybvw5")] @@ -264,3 +271,84 @@ physics_material_override = SubResource("4") [node name="Player" parent="." instance=ExtResource("4_ray4s")] transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -9.49833, -3.84189, 3.9334) + +[node name="touchScreenUi" type="CanvasLayer" parent="."] +script = ExtResource("5_7os5d") + +[node name="Virtual Joystick" parent="touchScreenUi" instance=ExtResource("5_smd4r")] +deadzone_size = 0.0 +clampzone_size = 100.0 + +[node name="performance" type="CheckButton" parent="touchScreenUi"] +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -197.0 +offset_bottom = 31.0 +grow_horizontal = 0 +focus_mode = 0 +theme = SubResource("Theme_21ljx") +text = "performance mode" +alignment = 1 +icon_alignment = 1 +expand_icon = true + +[node name="HBoxContainer" type="HBoxContainer" parent="touchScreenUi"] +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -256.0 +offset_top = -64.0 +offset_bottom = 64.0 +grow_horizontal = 0 +grow_vertical = 2 + +[node name="jump" type="Control" parent="touchScreenUi/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="touchScreenUi/HBoxContainer/jump"] +z_index = 5 +z_as_relative = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +text = "jump" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="jumpbtn" type="TouchScreenButton" parent="touchScreenUi/HBoxContainer/jump"] +self_modulate = Color(0, 0, 0, 1) +scale = Vector2(124, 124) +texture_normal = SubResource("CanvasTexture_7o5bd") +action = "jump" + +[node name="shoot" type="Control" parent="touchScreenUi/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="shoot" type="Label" parent="touchScreenUi/HBoxContainer/shoot"] +z_index = 5 +z_as_relative = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +text = "shoot" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="shoot2" type="TouchScreenButton" parent="touchScreenUi/HBoxContainer/shoot"] +self_modulate = Color(0, 0, 0, 1) +scale = Vector2(124, 124) +texture_normal = SubResource("CanvasTexture_7o5bd") +action = "shoot" + +[connection signal="toggled" from="touchScreenUi/performance" to="touchScreenUi" method="_on_check_button_toggled"] diff --git a/3d/platformer/player/bullet/bullet.gd b/3d/platformer/player/bullet/bullet.gd index ff7943956af..db639171f70 100644 --- a/3d/platformer/player/bullet/bullet.gd +++ b/3d/platformer/player/bullet/bullet.gd @@ -4,3 +4,6 @@ extends RigidBody3D ## If `true`, the bullet can hit enemies. This is set to `false` when the bullet ## hits an enemy so it can't hit an enemy multiple times while the bullet is fading out. var enabled := true + +func hide_omniLight() -> void: + $OmniLight3D.hide() diff --git a/3d/platformer/player/bullet/bullet.tscn b/3d/platformer/player/bullet/bullet.tscn index 841208ee61e..82ff16a7882 100644 --- a/3d/platformer/player/bullet/bullet.tscn +++ b/3d/platformer/player/bullet/bullet.tscn @@ -154,17 +154,18 @@ libraries = { } autoplay = "life" -[node name="CPUParticles3D" type="CPUParticles3D" parent="."] +[node name="CPUParticles3D" type="CPUParticles3D" parent="." groups=["bad_performer"]] cast_shadow = 0 amount = 16 lifetime = 0.4 +visibility_aabb = AABB(-4, -4, -4, 8, 8, 8) mesh = SubResource("SphereMesh_hnt4a") spread = 0.0 gravity = Vector3(0, 0, 0) scale_amount_curve = SubResource("Curve_4e8sm") color_ramp = SubResource("Gradient_ic2ol") -[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +[node name="CollisionShape3D" type="CollisionShape3D" parent="." groups=["bad_performer"]] shape = SubResource("SphereShape3D_vq2ey") [node name="OmniLight3D" type="OmniLight3D" parent="."] diff --git a/3d/platformer/player/player.gd b/3d/platformer/player/player.gd index dd3e97840d5..867f70ecebb 100644 --- a/3d/platformer/player/player.gd +++ b/3d/platformer/player/player.gd @@ -24,6 +24,8 @@ var jumping := false var prev_shoot := false var shoot_blend := 0.0 +static var performance_mode := false + # Number of coins collected. var coins := 0 @@ -67,7 +69,6 @@ func _physics_process(delta: float) -> void: movement_direction = movement_direction.normalized() var jump_attempt := Input.is_action_pressed(&"jump") - var shoot_attempt := Input.is_action_pressed(&"shoot") if is_on_floor(): var sharp_turn := horizontal_speed > 0.1 and \ @@ -150,10 +151,12 @@ func _physics_process(delta: float) -> void: shoot_blend *= 0.97 if (shoot_blend < 0): shoot_blend = 0 - + var shoot_attempt := Input.is_action_pressed(&"shoot") if shoot_attempt and not prev_shoot: shoot_blend = SHOOT_TIME var bullet := preload("res://player/bullet/bullet.tscn").instantiate() as Bullet + if performance_mode: + bullet.hide_omniLight() bullet.set_transform($Player/Skeleton/Bullet.get_global_transform().orthonormalized()) get_parent().add_child(bullet) bullet.set_linear_velocity( @@ -175,7 +178,6 @@ func _physics_process(delta: float) -> void: _animation_tree[&"parameters/air_dir/blend_amount"] = clampf(-velocity.y / 4 + 0.5, 0, 1) _animation_tree[&"parameters/gun/blend_amount"] = minf(shoot_blend, 1.0) - func adjust_facing(facing: Vector3, target: Vector3, step: float, adjust_rate: float, \ current_gn: Vector3) -> Vector3: var normal := target diff --git a/3d/platformer/player/player.tscn b/3d/platformer/player/player.tscn index e058c553db4..27860229f54 100644 --- a/3d/platformer/player/player.tscn +++ b/3d/platformer/player/player.tscn @@ -1,13 +1,9 @@ -[gd_scene load_steps=28 format=3 uid="uid://cc4idhykjp5f5"] +[gd_scene load_steps=24 format=3 uid="uid://cc4idhykjp5f5"] [ext_resource type="Script" path="res://player/player.gd" id="1"] [ext_resource type="Script" path="res://player/follow_camera.gd" id="2"] [ext_resource type="PackedScene" uid="uid://yd1e7ai2k5cr" path="res://player/player.glb" id="3_uccbe"] -[ext_resource type="Texture2D" uid="uid://kujhqacj3v72" path="res://player/controls/osb_up.webp" id="4_lmv6w"] -[ext_resource type="Texture2D" uid="uid://68sox6egj4j7" path="res://player/controls/osb_down.webp" id="5_4oxdy"] -[ext_resource type="Texture2D" uid="uid://r6qxvqi0unib" path="res://player/controls/osb_left.webp" id="6_k2dm4"] [ext_resource type="AudioStream" uid="uid://cdx3i7hr2acow" path="res://player/sound_shoot.wav" id="7"] -[ext_resource type="Texture2D" uid="uid://bw76q621n8fie" path="res://player/controls/osb_right.webp" id="7_yth2f"] [ext_resource type="AudioStream" uid="uid://bplqk77bffdxr" path="res://player/sound_jump.wav" id="8"] [sub_resource type="CapsuleShape3D" id="1"] @@ -79,13 +75,11 @@ node_connections = [&"air_dir", 0, &"Animation 3", &"air_dir", 1, &"Animation 4" random_pitch = 1.03 streams_count = 1 stream_0/stream = ExtResource("7") -stream_0/weight = 1.0 [sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_axa7i"] random_pitch = 1.03 streams_count = 1 stream_0/stream = ExtResource("8") -stream_0/weight = 1.0 [sub_resource type="Gradient" id="Gradient_p2tu5"] interpolation_mode = 2 @@ -118,15 +112,35 @@ script = ExtResource("2") [node name="Player" parent="." instance=ExtResource("3_uccbe")] [node name="Skeleton3D" parent="Player/Skeleton" index="0"] -bones/5/rotation = Quaternion(0.501129, -0.498869, -0.501128, 0.498869) -bones/9/rotation = Quaternion(-0.264667, 0.951702, -0.15503, -0.013433) -bones/10/rotation = Quaternion(0.744208, -0.433567, 0.504614, 0.0594899) -bones/11/rotation = Quaternion(0.264667, 0.951702, -0.15503, 0.013433) -bones/13/rotation = Quaternion(-0.000357303, 0.998602, 0.0504822, -0.0156872) -bones/14/rotation = Quaternion(0.720784, -0.0117194, -0.041935, 0.691791) -bones/15/rotation = Quaternion(0.998503, -0.0419896, 0.0282027, 0.0208377) -bones/16/rotation = Quaternion(0.000357169, 0.998602, 0.050483, 0.0156871) -bones/17/rotation = Quaternion(0.720784, 0.0117189, 0.0419352, 0.691791) +bones/1/position = Vector3(1.09056e-20, 2.10612, -6.88338e-14) +bones/1/rotation = Quaternion(1.42109e-13, -2.84217e-14, -7.28307e-22, 1) +bones/2/rotation = Quaternion(-1.42109e-13, -1.80682e-21, 4.58668e-21, 1) +bones/3/rotation = Quaternion(-0.020416, 1.27213e-08, -1.7937e-09, 0.999792) +bones/4/rotation = Quaternion(3.37177e-09, 0.996325, -0.08565, -9.39008e-07) +bones/5/rotation = Quaternion(0.501129, -0.498869, -0.501129, 0.498869) +bones/6/position = Vector3(-6.01139e-07, 0.0040059, -2.27374e-13) +bones/7/position = Vector3(3.05648e-08, 1.2429, 0.270992) +bones/8/rotation = Quaternion(0.744208, 0.433567, -0.504614, 0.0594899) +bones/9/rotation = Quaternion(-0.264667, 0.951702, -0.155029, -0.0134332) +bones/10/rotation = Quaternion(0.744208, -0.433567, 0.504614, 0.0594898) +bones/11/rotation = Quaternion(0.264667, 0.951702, -0.155029, 0.0134332) +bones/11/scale = Vector3(1, 1, 1) +bones/12/rotation = Quaternion(0.998503, 0.0419892, -0.0282026, 0.0208368) +bones/13/position = Vector3(4.87277e-08, 0.644635, -6.03109e-10) +bones/13/rotation = Quaternion(-0.000357039, 0.998602, 0.0504818, -0.0156871) +bones/14/rotation = Quaternion(0.720784, -0.0117192, -0.0419344, 0.691791) +bones/15/rotation = Quaternion(0.998503, -0.0419892, 0.0282027, 0.0208378) +bones/16/position = Vector3(-6.38546e-08, 0.644636, -8.27896e-10) +bones/16/rotation = Quaternion(0.000356988, 0.998602, 0.0504828, 0.015687) +bones/17/rotation = Quaternion(0.720784, 0.0117191, 0.0419345, 0.691791) +bones/18/position = Vector3(-4.35527e-07, 6.35228, 5.79659) +bones/18/rotation = Quaternion(1, -1.01905e-13, 7.54979e-08, -4.23517e-21) +bones/19/position = Vector3(0.518863, 0.204768, 3.89848e-08) +bones/20/position = Vector3(-0.518863, 0.204768, -3.89848e-08) +bones/21/position = Vector3(0.411677, 1.62881, 0.663951) +bones/22/position = Vector3(-0.411677, 1.62881, 0.66395) +bones/23/position = Vector3(2.62535, 2.59016, 0.186879) +bones/25/position = Vector3(1.57185, 3.44768, -0.510255) [node name="Robot" parent="Player/Skeleton/Skeleton3D" index="0"] layers = 2 @@ -186,42 +200,6 @@ parameters/scale/scale = 1.5 parameters/speed/blend_amount = 0 parameters/state/blend_amount = 0.0 -[node name="Forward" type="TouchScreenButton" parent="."] -visible = false -position = Vector2(72, 301) -texture_normal = ExtResource("4_lmv6w") -texture_pressed = ExtResource("4_lmv6w") -passby_press = true -action = "move_forward" -visibility_mode = 1 - -[node name="Backward" type="TouchScreenButton" parent="."] -visible = false -position = Vector2(72, 365) -texture_normal = ExtResource("5_4oxdy") -texture_pressed = ExtResource("5_4oxdy") -passby_press = true -action = "move_backwards" -visibility_mode = 1 - -[node name="Left" type="TouchScreenButton" parent="."] -visible = false -position = Vector2(29, 332) -texture_normal = ExtResource("6_k2dm4") -texture_pressed = ExtResource("6_k2dm4") -passby_press = true -action = "move_left" -visibility_mode = 1 - -[node name="Right" type="TouchScreenButton" parent="."] -visible = false -position = Vector2(114, 332) -texture_normal = ExtResource("7_yth2f") -texture_pressed = ExtResource("7_yth2f") -passby_press = true -action = "move_right" -visibility_mode = 1 - [node name="SoundShoot" type="AudioStreamPlayer" parent="."] stream = SubResource("AudioStreamRandomizer_basvh") @@ -229,7 +207,7 @@ stream = SubResource("AudioStreamRandomizer_basvh") stream = SubResource("AudioStreamRandomizer_axa7i") volume_db = -6.0 -[node name="BlobShadow" type="Decal" parent="."] +[node name="BlobShadow" type="Decal" parent="." groups=["bad_performer"]] size = Vector3(1.6, 12, 1.6) texture_albedo = SubResource("GradientTexture2D_kvc1x") albedo_mix = 0.8 diff --git a/3d/platformer/project.godot b/3d/platformer/project.godot index e392912784b..4726bb56aca 100644 --- a/3d/platformer/project.godot +++ b/3d/platformer/project.godot @@ -22,6 +22,14 @@ config/icon="res://icon.webp" gdscript/warnings/untyped_declaration=1 +[display] + +window/stretch/mode="canvas_items" + +[global_group] + +bad_performer="" + [input] ui_accept={ @@ -146,9 +154,9 @@ common/physics_ticks_per_second=120 [rendering] +renderer/rendering_method="mobile" lights_and_shadows/directional_shadow/size=8192 lights_and_shadows/directional_shadow/soft_shadow_filter_quality=3 -lights_and_shadows/positional_shadow/soft_shadow_filter_quality=0 textures/default_filters/anisotropic_filtering_level=4 textures/decals/filter=1 anti_aliasing/quality/msaa_3d=2 diff --git a/3d/platformer/stage/meshes/previews/corner_fix.webp.import b/3d/platformer/stage/meshes/previews/corner_fix.webp.import index 002f2ff7951..5b765707119 100644 --- a/3d/platformer/stage/meshes/previews/corner_fix.webp.import +++ b/3d/platformer/stage/meshes/previews/corner_fix.webp.import @@ -3,16 +3,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://ckwv7e3lpmorb" -path.s3tc="res://.godot/imported/corner_fix.webp-bc947c0527b474b1e52d39a93f6cd55a.s3tc.ctex" +path.etc2="res://.godot/imported/corner_fix.webp-bc947c0527b474b1e52d39a93f6cd55a.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["etc2_astc"], "vram_texture": true } [deps] source_file="res://stage/meshes/previews/corner_fix.webp" -dest_files=["res://.godot/imported/corner_fix.webp-bc947c0527b474b1e52d39a93f6cd55a.s3tc.ctex"] +dest_files=["res://.godot/imported/corner_fix.webp-bc947c0527b474b1e52d39a93f6cd55a.etc2.ctex"] [params] diff --git a/3d/platformer/stage/stage.tscn b/3d/platformer/stage/stage.tscn index 22af61863dc..905f20ac4c1 100644 --- a/3d/platformer/stage/stage.tscn +++ b/3d/platformer/stage/stage.tscn @@ -42,7 +42,7 @@ directional_shadow_mode = 0 directional_shadow_fade_start = 1.0 directional_shadow_max_distance = 55.0 -[node name="Reflection1" type="ReflectionProbe" parent="."] +[node name="Reflection1" type="ReflectionProbe" parent="." groups=["bad_performer"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.28208, 1, -1) intensity = 0.5 max_distance = 60.0 @@ -50,14 +50,14 @@ size = Vector3(35.9516, 20, 52.5818) origin_offset = Vector3(0, -1.5, 0) box_projection = true -[node name="Reflection2" type="ReflectionProbe" parent="."] +[node name="Reflection2" type="ReflectionProbe" parent="." groups=["bad_performer"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15, 0, 0) intensity = 0.5 size = Vector3(16, 5, 6) origin_offset = Vector3(0, -0.22168, 0) box_projection = true -[node name="Reflection3" type="ReflectionProbe" parent="."] +[node name="Reflection3" type="ReflectionProbe" parent="." groups=["bad_performer"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20, 0, 4) intensity = 0.5 max_distance = 18.7 @@ -65,7 +65,7 @@ size = Vector3(6, 6, 12) origin_offset = Vector3(0, -0.22168, 0) box_projection = true -[node name="Reflection7" type="ReflectionProbe" parent="."] +[node name="Reflection7" type="ReflectionProbe" parent="." groups=["bad_performer"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 17.0391, 6.19519, 1.14534) intensity = 0.5 max_distance = 18.7 @@ -73,7 +73,7 @@ size = Vector3(8, 6, 14) origin_offset = Vector3(0, -0.22168, 0) box_projection = true -[node name="Reflection4" type="ReflectionProbe" parent="."] +[node name="Reflection4" type="ReflectionProbe" parent="." groups=["bad_performer"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21, 1, 15) intensity = 0.5 max_distance = 60.0 @@ -81,14 +81,14 @@ size = Vector3(24, 20, 16) origin_offset = Vector3(-4.6, -1.4, 0) box_projection = true -[node name="Reflection5" type="ReflectionProbe" parent="."] +[node name="Reflection5" type="ReflectionProbe" parent="." groups=["bad_performer"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.5486, 1, 8) intensity = 0.5 max_distance = 60.0 size = Vector3(36.9944, 20, 44.786) origin_offset = Vector3(0, -6.5, 0) -[node name="Reflection6" type="ReflectionProbe" parent="."] +[node name="Reflection6" type="ReflectionProbe" parent="." groups=["bad_performer"]] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 25.0962, 0.999998, -15.4268) intensity = 0.5 max_distance = 60.0 diff --git a/3d/platformer/touch_screen_ui.gd b/3d/platformer/touch_screen_ui.gd new file mode 100644 index 00000000000..d2fee502bbb --- /dev/null +++ b/3d/platformer/touch_screen_ui.gd @@ -0,0 +1,13 @@ +extends CanvasLayer + +var player_script:= preload("res://player/player.gd") + +func _ready() -> void: + if DisplayServer.is_touchscreen_available():# and Input.get_connected_joypads().size()==0: + show() + InputMap.action_erase_events("shoot") + +func _on_check_button_toggled(toggled_on: bool) -> void: + player_script.performance_mode = toggled_on + for child in get_tree().get_nodes_in_group("bad_performer"): + child.visible = !toggled_on diff --git a/3d/platformer/virtual_joystick/textures/joystick_base_outline.png b/3d/platformer/virtual_joystick/textures/joystick_base_outline.png new file mode 100644 index 0000000000000000000000000000000000000000..7cae462a42a4cea25b231f28587b41b03775128c GIT binary patch literal 4827 zcmV<15+v=3P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D5^zaGK~#8N?VU}i zCDplx`ve1C$iRVvd(nYlLj)Z-aNs~tP`C~R9XJqdhyx)#5aJ*ZAsKj);2?w~I53ca zkthldj3l7JmTpn-LIe#_(xMlY2sT8BkcJi%yzf)>)$#1pd!PDN?b>_S&-=jV+GpFV ze%5-wy}tERtM-nWjq&x@UmsU;P1tv2SI91j&zH;KN*Ui>D*I2q5a(oH$i9+&!WZH* z+4=h8v5#eZ{y=tiZ*T7`Uz+~0gRF_10I@fYaBZZ`--v!2;7B+LhSU5tQk7Fl2C=GqP7n0eWC!-HBN9eaaDSJxJ z@=^88%$c==LiUozm}uW z!c3OQI!HLiN!gEN%?$OnVF$jYvv#h&Wbmk;qww3-*fF;FV|12$4omg+>8O= zF)7(hNYaDciWxv(6Pja|;atE*$DQ z8P0Nbqzq4Q>;7>LT9jW-)lo)|L~@Djr0id^O~W~!mpv#O?8Kq2?Yg)|uJzxtO+&eG zK3YCA6jUKM$o?YR6c=PK%N~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{bGt4^1L*-CE_WO@Zng|@Pw+3gG*=|nt9Si&Qb)tFvDQ?<0xWS=bT z2c7Wu^?6f#DRZc0dI2qkrm{Q{S+|EydbzA*^nl5kg-yAPDFqFMma?GH-E2>#6Q8Uu zAs#g)+5cNN$#xf&nZZEahXzVOW5e!utU?!F^76z63dk+V%ut=va+Ep;j5{>f z4U|4$1^g*b~LBZaz)I_v_Pna2+#H!AD;E5c|8%URqn841)? z)LEC2Dxl?r#lQSVy2ecX`J032> z6U56xXjE+JD#5=A_m&zZ8MQ;zu+(d5}%2-D0 zU$TkdGFY?6e9-s@&?AqC%q;SU2PXUhe3( z@Ad>`8D-iBEM#>{-xU=e57Dd}ay2j>e@h(N6r!^0(=i-U^@R$uuaK+Zw9Jl@gtCe< z>kEfen?QxySIE^s{Crm&-W)<@!;o#CjzQfyq}n7Z-0Ngr*Kw`lLm3lW$Ky1!g))$_ zZff1RjKi>zwBMhVh3=qanF7K@BqWVye7k~#o{5~>gcKvTZ%jBWi86TyX^^AvYkWfXW0@VL8?=T$l|3cL_^SG5;>^ZD8p2Un;rl%qv*>;j@n~ov z{vdl&c4{t;(J(s)If$Hv*!>>ay)v)OTI7uEY1y-Kil)CbJ7(=52a&T}rGyZSmSwIX z7$Fob1tC;3cra`1AWM+5Fv)eNjOEx2pH7)~WG~5HkW;)~ePi~qgR~%LVaS#6>t-1a zLrXJeXc`V+6pUUKMEh8<*0qJ^Q) zLMYbEV)Hk)%_SF1M$(69X7fqkaSO2?c90Dr$H6%oM`>oeuaNOQpPN;#%!>0J!_7@= zgs2%_Wk~fCz7Pjz-#?b|xp4@VwajYxbvqn8_WyJtpbGDe2-^Sv002ovPDHLkV1k1* BPWAu* literal 0 HcmV?d00001 diff --git a/3d/platformer/virtual_joystick/textures/joystick_base_outline.png.import b/3d/platformer/virtual_joystick/textures/joystick_base_outline.png.import new file mode 100644 index 00000000000..8fcf1f83134 --- /dev/null +++ b/3d/platformer/virtual_joystick/textures/joystick_base_outline.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bm30au8mjfc2f" +path="res://.godot/imported/joystick_base_outline.png-7371cc27054d3586a976ff242922b457.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://virtual_joystick/textures/joystick_base_outline.png" +dest_files=["res://.godot/imported/joystick_base_outline.png-7371cc27054d3586a976ff242922b457.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/3d/platformer/virtual_joystick/textures/joystick_tip.png b/3d/platformer/virtual_joystick/textures/joystick_tip.png new file mode 100644 index 0000000000000000000000000000000000000000..28c57acd8e3b022312f6d3f4a4d6bb6d81e048b3 GIT binary patch literal 1780 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D28l^TK~#8N?VZ1i z9z`6+?-dIRiz_0W;90uSgM4h;TlicV{=d`|kU``+Miz{eIxd?7PY3-I?dUGqbZZ zv!f-?+1c6IrR0FLM|xOVlU5|o-|x~m+tO{9Zb{dqO=&~AJQ|HS?=9XLA_I0Sc~*K_ zIxIaT)yWO%qV$9Goea9pNnh~75Sg%F$;;9U5|Pj*M9z8XOPOnel{@OVZHI0LtK!E0fZcju3q@)f161g!ZBcj5HG| zRAYrHWr+JN_*ODAvMFs!VMAP-K{Yj;0l0GT+~ujFZAu|SWCp#dpCoHD@-I_-|9 zGS?89LD(@iWj(5D(DQm+rpz3W%u{7CYHMaxhccurXEM_eMF(U5eIB)Ko5L#8H{5Y1 zQ>!ffAWz4Blj!Oi^>IsjOjTFr{IFRO@}XpA)DOSt9|eb#WJZXhgNOP=M{VQ$Mu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$7G1PWTF74B5KBu-+11!cPAy`&ihK9&dEYh$>m7!3yVr%gC8KKzO-@ew z8sATsFJJb)WejY^OiSURAIL~X7vwm5_N=c1iZwVmXmSZXz(%!?)M*C&kkJ*|Uc7kW zc6WFCIs&CqDR*sc&HJDQOFx&lK37||dQqWUI3=ItxoYC9cYjV9QY!FSEQ4J-8+85Qk$XQ=s zcRM;d+_tthcVWR;t(?4vTbrsEC8%98^6)r4J?&0ROn66;L!JYB&Zyd!RWC{$%Op)m zN$)5@+Z4?qfxb5i+#w*RF!GV+f_U6hgNIhzF9L0w@~GOl*a%)i2c$76Nt0-i7xGlK z)i$;$T3A2#nsnG956M}ROPT4FrpehMgES|1b_8XvU*b{PXhTyKNE>MkbjH?N2&GW3 z1!b0cJByioCB>x(&8iGC)rNvQZJQjQ$NaBZGva1?V4)9HfR z4*kV&R{2vht1@GBs;G3gp-;e53BxbS0WqEu&vE_-Q|yph$)MC200000NkvXXu0mjf DtkNO? literal 0 HcmV?d00001 diff --git a/3d/platformer/virtual_joystick/textures/joystick_tip_arrows.png.import b/3d/platformer/virtual_joystick/textures/joystick_tip_arrows.png.import new file mode 100644 index 00000000000..3b155ff8e80 --- /dev/null +++ b/3d/platformer/virtual_joystick/textures/joystick_tip_arrows.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dt13r06u87fib" +path="res://.godot/imported/joystick_tip_arrows.png-7681b297d95c3fc1ad24b8e054c68c3f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://virtual_joystick/textures/joystick_tip_arrows.png" +dest_files=["res://.godot/imported/joystick_tip_arrows.png-7681b297d95c3fc1ad24b8e054c68c3f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/3d/platformer/virtual_joystick/virtual_joystick.gd b/3d/platformer/virtual_joystick/virtual_joystick.gd new file mode 100644 index 00000000000..6674f4ab9fb --- /dev/null +++ b/3d/platformer/virtual_joystick/virtual_joystick.gd @@ -0,0 +1,169 @@ +class_name VirtualJoystick + +extends Control + +## A simple virtual joystick for touchscreens, with useful options. +## Github: https://github.com/MarcoFazioRandom/Virtual-Joystick-Godot + +# EXPORTED VARIABLE + +## The color of the button when the joystick is pressed. +@export var pressed_color := Color.GRAY + +## If the input is inside this range, the output is zero. +@export_range(0, 200, 1) var deadzone_size : float = 10 + +## The max distance the tip can reach. +@export_range(0, 500, 1) var clampzone_size : float = 75 + +enum Joystick_mode { + FIXED, ## The joystick doesn't move. + DYNAMIC, ## Every time the joystick area is pressed, the joystick position is set on the touched position. + FOLLOWING ## When the finger moves outside the joystick area, the joystick will follow it. +} + +## If the joystick stays in the same position or appears on the touched position when touch is started +@export var joystick_mode := Joystick_mode.FIXED + +enum Visibility_mode { + ALWAYS, ## Always visible + TOUCHSCREEN_ONLY, ## Visible on touch screens only + WHEN_TOUCHED ## Visible only when touched +} + +## If the joystick is always visible, or is shown only if there is a touchscreen +@export var visibility_mode := Visibility_mode.ALWAYS + +## If true, the joystick uses Input Actions (Project -> Project Settings -> Input Map) +@export var use_input_actions := true + +@export var action_left := "move_left" +@export var action_right := "move_right" +@export var action_up := "move_forward" +@export var action_down := "move_back" + +# PUBLIC VARIABLES + +## If the joystick is receiving inputs. +var is_pressed := false + +# The joystick output. +var output := Vector2.ZERO + +# PRIVATE VARIABLES + +var _touch_index : int = -1 + +@onready var _base := $Base +@onready var _tip := $Base/Tip + +@onready var _base_default_position : Vector2 = _base.position +@onready var _tip_default_position : Vector2 = _tip.position + +@onready var _default_color : Color = _tip.modulate + +# FUNCTIONS + +func _ready() -> void: + if not DisplayServer.is_touchscreen_available(): + hide() + + if visibility_mode == Visibility_mode.WHEN_TOUCHED: + hide() + +func _input(event: InputEvent) -> void: + if event is InputEventScreenTouch: + if event.pressed: + if _is_point_inside_joystick_area(event.position) and _touch_index == -1: + if joystick_mode == Joystick_mode.DYNAMIC or joystick_mode == Joystick_mode.FOLLOWING or (joystick_mode == Joystick_mode.FIXED and _is_point_inside_base(event.position)): + if joystick_mode == Joystick_mode.DYNAMIC or joystick_mode == Joystick_mode.FOLLOWING: + _move_base(event.position) + if visibility_mode == Visibility_mode.WHEN_TOUCHED: + show() + _touch_index = event.index + _tip.modulate = pressed_color + _update_joystick(event.position) + get_viewport().set_input_as_handled() + elif event.index == _touch_index: + _reset() + if visibility_mode == Visibility_mode.WHEN_TOUCHED: + hide() + get_viewport().set_input_as_handled() + elif event is InputEventScreenDrag: + if event.index == _touch_index: + _update_joystick(event.position) + get_viewport().set_input_as_handled() + +func _move_base(new_position: Vector2) -> void: + _base.global_position = new_position - _base.pivot_offset * get_global_transform_with_canvas().get_scale() + +func _move_tip(new_position: Vector2) -> void: + _tip.global_position = new_position - _tip.pivot_offset * _base.get_global_transform_with_canvas().get_scale() + +func _is_point_inside_joystick_area(point: Vector2) -> bool: + var x: bool = point.x >= global_position.x and point.x <= global_position.x + (size.x * get_global_transform_with_canvas().get_scale().x) + var y: bool = point.y >= global_position.y and point.y <= global_position.y + (size.y * get_global_transform_with_canvas().get_scale().y) + return x and y + +func _get_base_radius() -> Vector2: + return _base.size * _base.get_global_transform_with_canvas().get_scale() / 2 + +func _is_point_inside_base(point: Vector2) -> bool: + var _base_radius: = _get_base_radius() + var center : Vector2 = _base.global_position + _base_radius + var vector : Vector2 = point - center + if vector.length_squared() <= _base_radius.x * _base_radius.x: + return true + else: + return false + +func _update_joystick(touch_position: Vector2) -> void: + var _base_radius: = _get_base_radius() + var center : Vector2 = _base.global_position + _base_radius + var vector : Vector2 = touch_position - center + vector = vector.limit_length(clampzone_size) + + if joystick_mode == Joystick_mode.FOLLOWING and touch_position.distance_to(center) > clampzone_size: + _move_base(touch_position - vector) + + _move_tip(center + vector) + + if vector.length_squared() > deadzone_size * deadzone_size: + is_pressed = true + output = (vector - (vector.normalized() * deadzone_size)) / (clampzone_size - deadzone_size) + else: + is_pressed = false + output = Vector2.ZERO + + if use_input_actions: + # Release actions + if output.x >= 0 and Input.is_action_pressed(action_left): + Input.action_release(action_left) + if output.x <= 0 and Input.is_action_pressed(action_right): + Input.action_release(action_right) + if output.y >= 0 and Input.is_action_pressed(action_up): + Input.action_release(action_up) + if output.y <= 0 and Input.is_action_pressed(action_down): + Input.action_release(action_down) + # Press actions + if output.x < 0: + Input.action_press(action_left, -output.x) + if output.x > 0: + Input.action_press(action_right, output.x) + if output.y < 0: + Input.action_press(action_up, -output.y) + if output.y > 0: + Input.action_press(action_down, output.y) + +func _reset() -> void: + is_pressed = false + output = Vector2.ZERO + _touch_index = -1 + _tip.modulate = _default_color + _base.position = _base_default_position + _tip.position = _tip_default_position + # Release actions + if use_input_actions: + for action:String in [action_left, action_right, action_down, action_up]: + if Input.is_action_pressed(action): + Input.action_release(action) diff --git a/3d/platformer/virtual_joystick/virtual_joystick_scene.tscn b/3d/platformer/virtual_joystick/virtual_joystick_scene.tscn new file mode 100644 index 00000000000..6aef6b93d2f --- /dev/null +++ b/3d/platformer/virtual_joystick/virtual_joystick_scene.tscn @@ -0,0 +1,51 @@ +[gd_scene load_steps=4 format=3 uid="uid://dmr0fcamx7t56"] + +[ext_resource type="Script" path="res://virtual_joystick/virtual_joystick.gd" id="1_8x4dy"] +[ext_resource type="Texture2D" uid="uid://bm30au8mjfc2f" path="res://virtual_joystick/textures/joystick_base_outline.png" id="2_jhjs2"] +[ext_resource type="Texture2D" uid="uid://dt13r06u87fib" path="res://virtual_joystick/textures/joystick_tip_arrows.png" id="3_3etdg"] + +[node name="Virtual Joystick" type="Control"] +layout_mode = 3 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -308.0 +offset_right = 300.0 +offset_bottom = -8.0 +grow_vertical = 0 +script = ExtResource("1_8x4dy") + +[node name="Base" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -100.0 +offset_top = -100.0 +offset_right = 100.0 +offset_bottom = 100.0 +grow_horizontal = 2 +grow_vertical = 2 +pivot_offset = Vector2(100, 100) +mouse_force_pass_scroll_events = false +texture = ExtResource("2_jhjs2") +stretch_mode = 5 + +[node name="Tip" type="TextureRect" parent="Base"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -50.0 +offset_top = -50.0 +offset_right = 50.0 +offset_bottom = 50.0 +grow_horizontal = 2 +grow_vertical = 2 +pivot_offset = Vector2(50, 50) +texture = ExtResource("3_3etdg") +stretch_mode = 5