Now About Social Code
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2023-09-24 22:08:07 -0400
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2023-09-24 22:08:07 -0400
commit7a83dab6bba81f3dfda7179313bd92d492ecd533 (patch)
tree04f8031dfd0df4428f9b1384fbf48809f34e0bf5
parent76660c93401e09042bbd2b73325428b839fcdfc2 (diff)
Only climb tagged surfaces
-rw-r--r--prefab/player.tscn1
-rw-r--r--prefab/rock.tscn16
-rw-r--r--scenes/main.tscn1
-rw-r--r--scripts/level_gen.gd2
-rw-r--r--scripts/player.gd12
5 files changed, 24 insertions, 8 deletions
diff --git a/prefab/player.tscn b/prefab/player.tscn
index 809c557..d6c1432 100644
--- a/prefab/player.tscn
+++ b/prefab/player.tscn
@@ -13,6 +13,7 @@ size = Vector3(1, 2, 1)
size = Vector3(1.28475, 2, 1)
[node name="Player" type="CharacterBody3D"]
+collision_layer = 5
script = ExtResource("1_l6xtg")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
diff --git a/prefab/rock.tscn b/prefab/rock.tscn
index d6786da..2dac29d 100644
--- a/prefab/rock.tscn
+++ b/prefab/rock.tscn
@@ -1,14 +1,18 @@
[gd_scene load_steps=3 format=3 uid="uid://2a3fyuye46hm"]
-[sub_resource type="SphereShape3D" id="SphereShape3D_os5og"]
-
[sub_resource type="SphereMesh" id="SphereMesh_l2tu3"]
+height = 0.5
+is_hemisphere = true
+
+[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_ugqi6"]
+points = PackedVector3Array(-0.0915212, 0.0475939, 0.4884, -0.0919359, 0.000692064, -0.490613, -0.153229, 0.000846659, -0.474955, -0.0148097, 0.498986, -0.0148068, 0.490615, 0.000690721, 0.0919184, -0.490615, 0.000690721, 0.0919184, 0.281809, 0.231476, -0.341135, 0.308801, 0.334513, 0.205765, -0.264216, 0.305039, -0.293598, -0.263554, 0.363489, 0.219646, 0.258919, 0.00235193, 0.426422, 0.0295862, 0.364661, 0.340406, 0.353233, 0.000281841, -0.353164, 0.384702, 0.305395, -0.0887173, 0.0295865, 0.364663, -0.340411, -0.453708, 0.125113, -0.16627, -0.355672, 0.349959, -0.0147626, -0.30422, 0.00269272, 0.395447, 0.219612, 0.436624, -0.102355, 0.0150726, 0.170472, -0.468959, -0.382247, 0.00139124, -0.321063, -0.312984, 0.231319, 0.313016, 0.253421, 0.18662, 0.387575, 0.453689, 0.125168, -0.166263, 0.0734603, 0.466961, 0.161729, -0.176449, 0.45221, -0.117548, 0.453693, 0.125166, 0.166265, -0.45087, 0.186028, 0.105164, -0.0896107, 0.231262, 0.433361, -0.147992, 0.453473, 0.147963, -0.209696, 0.171289, -0.419405, 0.153229, 0.000846659, -0.474955)
[node name="Rock" type="RigidBody3D"]
collision_layer = 3
-[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
-shape = SubResource("SphereShape3D_os5og")
-
-[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D"]
+[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_l2tu3")
+skeleton = NodePath("")
+
+[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
+shape = SubResource("ConvexPolygonShape3D_ugqi6")
diff --git a/scenes/main.tscn b/scenes/main.tscn
index 9ece0e8..c1339d1 100644
--- a/scenes/main.tscn
+++ b/scenes/main.tscn
@@ -59,6 +59,7 @@ seed_text = NodePath("../RichTextLabel/SeedText")
[node name="StaticBody3D" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.7194, 5, -6.35033)
+collision_layer = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("BoxShape3D_kjqqf")
diff --git a/scripts/level_gen.gd b/scripts/level_gen.gd
index 66f465a..988bace 100644
--- a/scripts/level_gen.gd
+++ b/scripts/level_gen.gd
@@ -155,6 +155,8 @@ func _ready():
collision_shape.set_shape(col_mesh)
var static_body = StaticBody3D.new()
+ static_body.collision_layer = 0xb101
+ static_body.collision_mask = 0xb101
static_body.add_child(collision_shape)
static_body.add_child(m)
diff --git a/scripts/player.gd b/scripts/player.gd
index f6a63a0..2d4db99 100644
--- a/scripts/player.gd
+++ b/scripts/player.gd
@@ -1,6 +1,5 @@
extends CharacterBody3D
-
const SPEED = 5.0
const RUN_SPEED = 1.5 * SPEED
const JUMP_VELOCITY = 4.5
@@ -90,7 +89,16 @@ func _physics_process(delta):
var climb_direction_fwd = Vector3()
var climb_direction_right = Vector3()
- if is_on_wall() and stamina > 0:
+
+ var valid_climb = false
+ if is_on_wall():
+ for col in get_slide_collision_count():
+ var col_obj = get_slide_collision(col)
+ print(col_obj.get_collider().collision_layer)
+ if col_obj.get_collider().collision_layer & 0b100:
+ valid_climb = true
+
+ if valid_climb and stamina > 0:
last_wall_direction = get_wall_normal()
climbing = true
stam_consumption += RUN_CONSUMPTION