diff --git a/scenes/heroes/0.tscn b/scenes/heroes/0.tscn index 003a6e3..c6941cf 100644 --- a/scenes/heroes/0.tscn +++ b/scenes/heroes/0.tscn @@ -5,7 +5,7 @@ [ext_resource path="res://assets/heroes/0_head.obj" type="ArrayMesh" id=3] [ext_resource path="res://assets/heroes/0.obj" type="ArrayMesh" id=4] -[node name="RigidBody" instance=ExtResource( 1 )] +[node name="RigidBody" index="0" instance=ExtResource( 1 )] script = ExtResource( 2 ) @@ -13,6 +13,7 @@ script = ExtResource( 2 ) transform = Transform( 0.376731, 0, 6.23012e-08, -6.13772e-08, 1.03258e-14, 0.382402, 0, -0.389018, 1.01502e-14, 0, 0.104562, -0.0173855 ) mesh = ExtResource( 3 ) +material/0 = null [node name="MainMesh" parent="Yaw" index="1"] diff --git a/scenes/player.tscn b/scenes/player.tscn index f31380c..3a0be10 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=10 format=2] [ext_resource path="res://scripts/player.gd" type="Script" id=1] [ext_resource path="res://scripts/tp_camera.gd" type="Script" id=2] @@ -22,7 +22,7 @@ subdivide_width = 0 subdivide_height = 0 subdivide_depth = 0 -[sub_resource type="CapsuleMesh" id=4] +[sub_resource type="CapsuleMesh" id=5] radius = 0.4 mid_height = 0.1 @@ -30,7 +30,14 @@ radial_segments = 64 rings = 8 _sections_unfolded = [ "Resource" ] -[sub_resource type="SpatialMaterial" id=5] +[sub_resource type="CubeMesh" id=6] + +size = Vector3( 2, 2, 2 ) +subdivide_width = 0 +subdivide_height = 0 +subdivide_depth = 0 + +[sub_resource type="SpatialMaterial" id=7] render_priority = 0 flags_transparent = false @@ -80,7 +87,6 @@ uv2_triplanar = false uv2_triplanar_sharpness = 1.0 proximity_fade_enable = false distance_fade_enable = false -_sections_unfolded = [ "Albedo", "Flags", "Parameters", "Vertex Color" ] [node name="RigidBody" type="RigidBody" index="0" groups=[ "player", @@ -161,7 +167,7 @@ lod_max_hysteresis = 0.0 mesh = SubResource( 3 ) skeleton = NodePath("..") material/0 = null -_sections_unfolded = [ "Transform" ] +_sections_unfolded = [ "Transform", "material" ] [node name="MainMesh" type="MeshInstance" parent="Yaw" index="1"] @@ -175,9 +181,9 @@ lod_min_distance = 0.0 lod_min_hysteresis = 0.0 lod_max_distance = 0.0 lod_max_hysteresis = 0.0 -mesh = SubResource( 4 ) +mesh = SubResource( 5 ) skeleton = NodePath("..") -material/0 = SubResource( 5 ) +material/0 = null _sections_unfolded = [ "Transform", "material" ] [node name="MasterOnly" type="Node" parent="." index="4"] @@ -253,15 +259,32 @@ far = 250.0 enabled = true exclude_parent = true -cast_to = Vector3( 0, 0, -100 ) +cast_to = Vector3( 0, 0, -500 ) collision_mask = 1 _sections_unfolded = [ "Transform" ] -[node name="NamePosition" type="Spatial" parent="." index="6"] +[node name="MaterialSettings" type="MeshInstance" parent="." index="6"] + +visible = false +layers = 1 +material_override = null +cast_shadow = 1 +extra_cull_margin = 0.0 +use_in_baked_light = false +lod_min_distance = 0.0 +lod_min_hysteresis = 0.0 +lod_max_distance = 0.0 +lod_max_hysteresis = 0.0 +mesh = SubResource( 6 ) +skeleton = NodePath("..") +material/0 = SubResource( 7 ) +_sections_unfolded = [ "material" ] + +[node name="NamePosition" type="Spatial" parent="." index="7"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.56117, 0 ) -[node name="PlayerName" type="Label" parent="." index="7"] +[node name="PlayerName" type="Label" parent="." index="8"] anchor_left = 0.0 anchor_top = 0.0 diff --git a/scenes/wall.tscn b/scenes/wall.tscn index 9db4c98..5aadbe6 100644 --- a/scenes/wall.tscn +++ b/scenes/wall.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://scripts/heroes/0-wall.gd" type="Script" id=1] +[ext_resource path="res://scripts/heroes/1-wall.gd" type="Script" id=1] [sub_resource type="CubeMesh" id=1] @@ -13,7 +13,7 @@ subdivide_depth = 0 extents = Vector3( 1.5, 1.5, 0.25 ) -[node name="StaticBody" type="StaticBody"] +[node name="StaticBody" type="StaticBody" index="0"] input_ray_pickable = true input_capture_on_drag = false diff --git a/scripts/player.gd b/scripts/player.gd index 19eb30f..ff83e1c 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -32,8 +32,8 @@ var tp_camera = "TPCamera" var master_only = "MasterOnly" var master_player -var friend_color = Color("#073a98") # Blue -var enemy_color = Color("#62071a") # Red +var friend_color = Color("#4abfe5") # Blue +var enemy_color = Color("#f04273") # Red var ai_instanced = false @@ -109,7 +109,12 @@ func begin(): color = friend_color else: color = enemy_color - var mat = SpatialMaterial.new() + # We have a base MaterialSettings to use inheritance with heroes + # Unfortunately we cannot do this with the actual meshes, + # because godot decides if you change the mesh you wanted to change the material as well + # So "MaterialSettings" is a dummy mesh in player.tscn that's hidden + # We call .duplicate() so we can set this color without messing with other players' colors + var mat = get_node("MaterialSettings").get_surface_material(0).duplicate() mat.albedo_color = color get_node("Yaw/MainMesh").set_surface_material(0, mat) get_node("Yaw/Pitch/RotatedHead").set_surface_material(0, mat) @@ -175,7 +180,15 @@ func control_player(state): direction = direction.normalized() var ray = get_node("Ray") - if get_colliding_bodies(): # We can navigate normally, we have a surface + # Detect jumpable + var jumpable = false + var jump_dot = 0.8 # If normal.dot(up) > jump_dot, we can jump + for i in range(state.get_contact_count()): + var n = state.get_contact_local_normal(i) + if n.dot(Vector3(0,1,0)) > jump_dot: + jumpable = true + + if jumpable: # We can navigate normally, we have a surface var up = state.get_total_gravity().normalized() var normal = ray.get_collision_normal() var floor_velocity = Vector3() @@ -189,16 +202,7 @@ func control_player(state): state.set_linear_velocity(lin_v) if Input.is_action_just_pressed("jump"): - # This may be kinda expensive but we only check while pressing jump so it's ok - # Detect jumpable - var jump_dot = 0.8 # If normal.dot(up) > jump_dot, we can jump - var jumpable = false - for i in range(state.get_contact_count()): - var n = state.get_contact_local_normal(0) - if n.dot(Vector3(0,1,0)) > jump_dot: - jumpable = true - if jumpable: - state.apply_impulse(Vector3(), normal * jump_speed * get_mass()) + state.apply_impulse(Vector3(), normal * jump_speed * get_mass()) else: var accel = (1 + switch_charge * air_speed_build) * air_accel