From abe877c5daa5d2263bbf36e2ef63228f10e9ab6b Mon Sep 17 00:00:00 2001 From: derek Date: Thu, 26 Jun 2025 10:54:22 -0500 Subject: [PATCH] mostly have mouse look working, need to figure out why collision mask binary 8 also includes 6?? --- Prefabs/PlayerCamera.tscn | 14 +++++++++++++- Prefabs/player.tscn | 35 ++++++++++++++++++----------------- Scenes/TestScene1.tscn | 6 +++++- Scripts/mouseDebug.gd | 6 ++++++ Scripts/mouseDebug.gd.uid | 1 + Scripts/mouse_pos.gd | 4 ++-- Scripts/player_states.gd | 4 ++-- mousedebug.tscn | 11 +++++++++++ 8 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 Scripts/mouseDebug.gd create mode 100644 Scripts/mouseDebug.gd.uid create mode 100644 mousedebug.tscn diff --git a/Prefabs/PlayerCamera.tscn b/Prefabs/PlayerCamera.tscn index f6df874..6472698 100644 --- a/Prefabs/PlayerCamera.tscn +++ b/Prefabs/PlayerCamera.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://hmyrn2pbbhpm"] +[gd_scene load_steps=8 format=3 uid="uid://hmyrn2pbbhpm"] [ext_resource type="Script" uid="uid://bici4k5vkuoos" path="res://Scripts/player_camera.gd" id="1_ocbkm"] [ext_resource type="Script" uid="uid://bnqpqdped5uw2" path="res://Scripts/camera_Look.gd" id="2_8uhk6"] @@ -17,6 +17,9 @@ bg_color = Color(0.458824, 0, 0.145098, 1) [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8uhk6"] bg_color = Color(0.457868, 0.677542, 0.145981, 1) +[sub_resource type="BoxShape3D" id="BoxShape3D_8uhk6"] +size = Vector3(30, 1, 30) + [node name="CameraFollow" type="Node3D"] script = ExtResource("1_ocbkm") @@ -63,3 +66,12 @@ size_flags_horizontal = 0 size_flags_vertical = 0 theme = ExtResource("3_8uhk6") text = "Gold: 35" + +[node name="MouseTable" type="Area3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0) +collision_layer = 128 +collision_mask = 128 +priority = 1 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="MouseTable"] +shape = SubResource("BoxShape3D_8uhk6") diff --git a/Prefabs/player.tscn b/Prefabs/player.tscn index 70dca71..9b458aa 100644 --- a/Prefabs/player.tscn +++ b/Prefabs/player.tscn @@ -36,22 +36,6 @@ tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = PackedFloat32Array(0, 1, 0.652269, 0.475497, -0.696594) -[sub_resource type="Animation" id="Animation_hck1p"] -resource_name = "dodge" -step = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Body:rotation") -tracks/0/interp = 2 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.3), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector3(0, 0, 0), Vector3(0, 0, 6.28319)] -} - [sub_resource type="Animation" id="Animation_4qbli"] resource_name = "attack" length = 0.5 @@ -70,6 +54,23 @@ tracks/1/interp = 2 tracks/1/loop_wrap = true tracks/1/keys = PackedFloat32Array(0, 1, 0, -0.86255, 0, 0.505973, 0.166667, 1, 0, 0.949105, 0, -0.314961, 0.193146, 1, 0, 0.949105, 0, -0.314961, 0.3, 1, 0, -0.371061, 0, 0.928609, 0.433352, 1, 0, -0.86255, 0, 0.505973) +[sub_resource type="Animation" id="Animation_hck1p"] +resource_name = "dodge" +length = 0.3 +step = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Body:rotation") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.3), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, 0, 6.28319)] +} + [sub_resource type="AnimationLibrary" id="AnimationLibrary_4qbli"] _data = { &"RESET": SubResource("Animation_juxdh"), @@ -115,7 +116,7 @@ metadata/extras = { transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, -0.5, 0.0393383) [node name="ShittySword" type="MeshInstance3D" parent="Body"] -transform = Transform3D(-0.487984, 0, -0.872853, 0, 1, 0, 0.872853, 0, -0.487984, 0.652269, 0.475497, -0.696594) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.652269, 0.475497, -0.696594) mesh = SubResource("BoxMesh_5wxv7") skeleton = NodePath("../..") diff --git a/Scenes/TestScene1.tscn b/Scenes/TestScene1.tscn index 34709ca..e3fa784 100644 --- a/Scenes/TestScene1.tscn +++ b/Scenes/TestScene1.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://dbqyyunvx6fdj"] +[gd_scene load_steps=15 format=3 uid="uid://dbqyyunvx6fdj"] [ext_resource type="PackedScene" uid="uid://hmyrn2pbbhpm" path="res://Prefabs/PlayerCamera.tscn" id="2_qq11w"] [ext_resource type="PackedScene" uid="uid://bacgd5lmvaxea" path="res://Prefabs/player.tscn" id="3_hfnh2"] @@ -9,6 +9,7 @@ [ext_resource type="PackedScene" uid="uid://d0u2u3cvfkdlj" path="res://Assets/Models/Test1.blend" id="8_46b76"] [ext_resource type="PackedScene" uid="uid://dctwrgdviw2bq" path="res://Prefabs/rat.tscn" id="8_igv2b"] [ext_resource type="PackedScene" uid="uid://1shngq3vrbu" path="res://coin_spawner.tscn" id="9_46b76"] +[ext_resource type="PackedScene" uid="uid://jkl8odkxg2s2" path="res://mousedebug.tscn" id="10_tadml"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_31lxn"] sky_top_color = Color(0.1, 0.1, 0.1, 1) @@ -165,3 +166,6 @@ transform = Transform3D(0.0790682, 0, 0.996869, 0, 1, 0, -0.996869, 0, 0.0790682 [node name="CoinSpawner" parent="." instance=ExtResource("9_46b76")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.81324, 3.94453, 0.757049) + +[node name="MOUSEDEBUG" parent="." instance=ExtResource("10_tadml")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.21551, 0.500001, -0.339623) diff --git a/Scripts/mouseDebug.gd b/Scripts/mouseDebug.gd new file mode 100644 index 0000000..f20edd3 --- /dev/null +++ b/Scripts/mouseDebug.gd @@ -0,0 +1,6 @@ +extends Node3D + +func _process(delta: float) -> void: + var mouse_pos = MousePos.get_mouse_world_position(00001000) + if mouse_pos != null: + global_position = mouse_pos diff --git a/Scripts/mouseDebug.gd.uid b/Scripts/mouseDebug.gd.uid new file mode 100644 index 0000000..9bc245d --- /dev/null +++ b/Scripts/mouseDebug.gd.uid @@ -0,0 +1 @@ +uid://cne68wmdyr4ld diff --git a/Scripts/mouse_pos.gd b/Scripts/mouse_pos.gd index baf70b1..cd80baa 100644 --- a/Scripts/mouse_pos.gd +++ b/Scripts/mouse_pos.gd @@ -3,7 +3,7 @@ extends Node3D -const RAY_LENGTH := 1000 +const RAY_LENGTH := 5000 """ Uses default collision_mask. But can be overrided for custom collision @@ -33,7 +33,7 @@ func _do_raycast_on_mouse_position(collision_mask: int = 0b00000000_00000000_000 query.collide_with_areas = true query.collision_mask = collision_mask - var result = space_state.intersect_ray(query) # raycast result + var result = space_state.intersect_ray(query) # raycast result return result diff --git a/Scripts/player_states.gd b/Scripts/player_states.gd index f271d3a..222ca44 100644 --- a/Scripts/player_states.gd +++ b/Scripts/player_states.gd @@ -39,9 +39,9 @@ func apply_gravity(delta): character.velocity.y -= 9.8 * delta func body_look_at_mouse(): - var mouse_raycast = MousePos.get_mouse_world_position() + var mouse_raycast = MousePos.get_mouse_world_position(1000) if mouse_raycast != null: - character.body.look_at(Vector3(mouse_raycast.x,character.body.global_position.y,mouse_raycast.y),Vector3.UP) + character.body.look_at(Vector3(mouse_raycast.x,character.body.global_position.y,mouse_raycast.z),Vector3.UP) func standard_movement(delta): if character.is_on_floor(): diff --git a/mousedebug.tscn b/mousedebug.tscn new file mode 100644 index 0000000..1b73467 --- /dev/null +++ b/mousedebug.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=3 format=3 uid="uid://jkl8odkxg2s2"] + +[ext_resource type="Script" uid="uid://cne68wmdyr4ld" path="res://Scripts/mouseDebug.gd" id="1_ehadm"] + +[sub_resource type="SphereMesh" id="SphereMesh_ehadm"] + +[node name="MOUSEDEBUG" type="Node3D"] +script = ExtResource("1_ehadm") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +mesh = SubResource("SphereMesh_ehadm")