From: Clifton Palmer Date: Fri, 20 Dec 2024 10:46:57 +0000 (+0200) Subject: Renabled collision for vehicles by putting vehicle and environment on different mask... X-Git-Tag: 0.9.0~4 X-Git-Url: http://git.purplebirdman.com/lightcycles.git/commitdiff_plain/f0a8b4b6ed5b689dc505fe5a6266bef9a649057d?ds=sidebyside;hp=50bbcd345ad197834435d5a7aa375d8f41b3e8e8 Renabled collision for vehicles by putting vehicle and environment on different mask than walls --- diff --git a/map/world.tscn b/map/world.tscn index 8a8f968..25d96e9 100644 --- a/map/world.tscn +++ b/map/world.tscn @@ -86,11 +86,14 @@ shape = SubResource("ConcavePolygonShape3D_qttgn") [node name="Player1" parent="." instance=ExtResource("1_3tqxd")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -16) +color = Color(1, 0.843137, 0, 1) +speed = 5.0 distance = 5.0 [node name="Player2" parent="." instance=ExtResource("1_3tqxd")] transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 16) color = Color(1, 0, 0, 1) +speed = 5.0 distance = 5.0 [node name="SplitScreenContainer" type="GridContainer" parent="."] @@ -110,7 +113,7 @@ stretch = true [node name="SubViewport" type="SubViewport" parent="SplitScreenContainer/SubViewportContainer"] handle_input_locally = false -size = Vector2i(2, 2) +size = Vector2i(3456, 970) render_target_update_mode = 4 [node name="SubViewportContainer2" type="SubViewportContainer" parent="SplitScreenContainer"] @@ -121,7 +124,7 @@ stretch = true [node name="SubViewport2" type="SubViewport" parent="SplitScreenContainer/SubViewportContainer2"] handle_input_locally = false -size = Vector2i(2, 2) +size = Vector2i(3456, 970) render_target_update_mode = 4 [connection signal="playerDestroyed" from="Player1" to="." method="_on_player_destroyed"] diff --git a/player/player.gd b/player/player.gd index 42300fe..3cd1522 100644 --- a/player/player.gd +++ b/player/player.gd @@ -8,6 +8,7 @@ signal playerRestart @onready var _skin = $skin +@onready var _ray = $RayCast3D @export_category("Appearance") @@ -51,10 +52,18 @@ func _physics_process(_delta: float) -> void: if _state == state.ALIVE: velocity = global_transform.basis.z * speed move_and_slide() - if velocity.length() == 0: + if _ray_intersect_length() < 0.05 or velocity.length() < 0.02: _explode() +func _ray_intersect_length() -> float: + if _ray.is_colliding(): + var point: Vector3 = _ray.get_collision_point() + var v: Vector3 = _ray.global_position - point + return v.length() + else: + return INF + func _explode() -> void: _skin.visible = false _state = state.DEAD diff --git a/player/player.tscn b/player/player.tscn index 1282f9c..bcc94c5 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -4,17 +4,21 @@ [ext_resource type="PackedScene" uid="uid://d13jnq5vpvhl0" path="res://skins/bike/bike.tscn" id="1_m3abw"] [sub_resource type="BoxShape3D" id="BoxShape3D_tm1pp"] -size = Vector3(0.233, 0.458, 0.0839297) +size = Vector3(0.242, 0.458, 0.077) [node name="Player" type="CharacterBody3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.367284) +axis_lock_linear_y = true +axis_lock_angular_x = true +axis_lock_angular_z = true +floor_constant_speed = true script = ExtResource("1_kh0vu") [node name="skin" parent="." instance=ExtResource("1_m3abw")] unique_name_in_owner = true +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.363836) [node name="CollisionShape3D" type="CollisionShape3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00212288, 0.234772, 0.415421) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.237295, 0.11965) shape = SubResource("BoxShape3D_tm1pp") [node name="SpringArm3D" type="SpringArm3D" parent="."] @@ -22,5 +26,6 @@ transform = Transform3D(-1, -2.99003e-08, 8.21505e-08, 0, 0.939693, 0.34202, -8. [node name="Camera3D" type="Camera3D" parent="SpringArm3D"] -[node name="WallOrigin" type="Node3D" parent="." groups=["wall_origin"]] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.544742) +[node name="RayCast3D" type="RayCast3D" parent="."] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.172602, 0) +collision_mask = 3 diff --git a/player/player_wall.tscn b/player/player_wall.tscn index 727f473..bca3ea1 100644 --- a/player/player_wall.tscn +++ b/player/player_wall.tscn @@ -12,8 +12,8 @@ uv1_world_triplanar = true material = SubResource("StandardMaterial3D_sk1tc") size = Vector3(1, 0.02, 1) -[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_71bu6"] -data = PackedVector3Array(-0.5, 0.005, 0.5, 0.5, 0.005, 0.5, -0.5, -0.005, 0.5, 0.5, 0.005, 0.5, 0.5, -0.005, 0.5, -0.5, -0.005, 0.5, 0.5, 0.005, -0.5, -0.5, 0.005, -0.5, 0.5, -0.005, -0.5, -0.5, 0.005, -0.5, -0.5, -0.005, -0.5, 0.5, -0.005, -0.5, 0.5, 0.005, 0.5, 0.5, 0.005, -0.5, 0.5, -0.005, 0.5, 0.5, 0.005, -0.5, 0.5, -0.005, -0.5, 0.5, -0.005, 0.5, -0.5, 0.005, -0.5, -0.5, 0.005, 0.5, -0.5, -0.005, -0.5, -0.5, 0.005, 0.5, -0.5, -0.005, 0.5, -0.5, -0.005, -0.5, 0.5, 0.005, 0.5, -0.5, 0.005, 0.5, 0.5, 0.005, -0.5, -0.5, 0.005, 0.5, -0.5, 0.005, -0.5, 0.5, 0.005, -0.5, -0.5, -0.005, 0.5, 0.5, -0.005, 0.5, -0.5, -0.005, -0.5, 0.5, -0.005, 0.5, 0.5, -0.005, -0.5, -0.5, -0.005, -0.5) +[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_aaxpr"] +points = PackedVector3Array(0.508, 0.014, 0.5, -0.508, -0.018, -0.5, -0.508, 0.014, -0.5, 0.508, -0.018, -0.5, -0.508, -0.018, 0.5, -0.508, 0.014, 0.5, 0.508, 0.014, -0.5, 0.508, -0.018, 0.5) [node name="PlayerWall" type="Node3D"] script = ExtResource("1_rj8im") @@ -23,6 +23,14 @@ transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, mesh = SubResource("BoxMesh_p4d0s") [node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"] +collision_layer = 2 +collision_mask = 2 +axis_lock_linear_x = true +axis_lock_linear_y = true +axis_lock_linear_z = true +axis_lock_angular_x = true +axis_lock_angular_y = true +axis_lock_angular_z = true [node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] -shape = SubResource("ConcavePolygonShape3D_71bu6") +shape = SubResource("ConvexPolygonShape3D_aaxpr")