Tint player color based on team
This commit is contained in:
parent
01876de2e7
commit
72a35ab568
@ -4,15 +4,16 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://cbvxh8xp8ilac" path="res://assets/Soldier.png" id="2_n4j5p"]
|
[ext_resource type="Texture2D" uid="uid://cbvxh8xp8ilac" path="res://assets/Soldier.png" id="2_n4j5p"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_n4j5p"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_n4j5p"]
|
||||||
|
resource_local_to_scene = true
|
||||||
albedo_texture = ExtResource("2_n4j5p")
|
albedo_texture = ExtResource("2_n4j5p")
|
||||||
texture_filter = 0
|
texture_filter = 0
|
||||||
|
|
||||||
[node name="SoldierM" unique_id=1868587353 instance=ExtResource("1_bn1bx")]
|
[node name="SoldierM" unique_id=1868587353 instance=ExtResource("1_bn1bx")]
|
||||||
|
|
||||||
[node name="Male_IK_HAND_R" parent="Aim_Control" parent_id_path=PackedInt32Array(1488925479) index="1" unique_id=1011336848]
|
[node name="Male_IK_HAND_R" parent="Aim_Control" parent_id_path=PackedInt32Array(490699733) index="1" unique_id=1663306107]
|
||||||
transform = Transform3D(0.005883459, -0.29583848, 0.4030446, -0.40563864, 0.23280492, 0.17680238, -0.29227144, -0.3290613, -0.23726773, 0.005743145, 1.1526048e-05, -0.001571659)
|
transform = Transform3D(0.005883459, -0.29583848, 0.4030446, -0.40563864, 0.23280492, 0.17680238, -0.29227144, -0.3290613, -0.23726773, 0.005743145, 1.1526048e-05, -0.001571659)
|
||||||
|
|
||||||
[node name="Skeleton3D" parent="Soldier" parent_id_path=PackedInt32Array(1731022909) index="0" unique_id=1317624294]
|
[node name="Skeleton3D" parent="Soldier" parent_id_path=PackedInt32Array(1101404322) index="0" unique_id=1074852808]
|
||||||
bones/2/rotation = Quaternion(0.95160115, 2.0944638e-08, 2.3653786e-08, -0.30733573)
|
bones/2/rotation = Quaternion(0.95160115, 2.0944638e-08, 2.3653786e-08, -0.30733573)
|
||||||
bones/3/rotation = Quaternion(-0.35209325, 4.091232e-08, 1.5390487e-08, 0.93596494)
|
bones/3/rotation = Quaternion(-0.35209325, 4.091232e-08, 1.5390487e-08, 0.93596494)
|
||||||
bones/4/rotation = Quaternion(0.7398268, -2.6881363e-08, 7.0005823e-09, 0.6727974)
|
bones/4/rotation = Quaternion(0.7398268, -2.6881363e-08, 7.0005823e-09, 0.6727974)
|
||||||
@ -29,5 +30,5 @@ bones/19/rotation = Quaternion(-1.332124e-08, -2.4520514e-08, -0.15752357, 0.987
|
|||||||
bones/20/rotation = Quaternion(-0.14214668, -0.45634764, -0.17772992, 0.86020535)
|
bones/20/rotation = Quaternion(-0.14214668, -0.45634764, -0.17772992, 0.86020535)
|
||||||
bones/22/position = Vector3(0.012593047, -0.0085772155, 0.0021641199)
|
bones/22/position = Vector3(0.012593047, -0.0085772155, 0.0021641199)
|
||||||
|
|
||||||
[node name="Soldier_Male_Mesh" parent="Soldier/Skeleton3D" index="0" unique_id=1081951616]
|
[node name="Soldier_Male_Mesh" parent="Soldier/Skeleton3D" index="0" unique_id=1117347105]
|
||||||
surface_material_override/0 = SubResource("StandardMaterial3D_n4j5p")
|
surface_material_override/0 = SubResource("StandardMaterial3D_n4j5p")
|
||||||
|
|||||||
@ -4,6 +4,12 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://ncxcmgdit2j1" path="res://mesh/soldier_m.tscn" id="1_sxefq"]
|
[ext_resource type="PackedScene" uid="uid://ncxcmgdit2j1" path="res://mesh/soldier_m.tscn" id="1_sxefq"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ci8r4lgijtalh" path="res://scenes/player/ball_weapon.tscn" id="2_jbny0"]
|
[ext_resource type="PackedScene" uid="uid://ci8r4lgijtalh" path="res://scenes/player/ball_weapon.tscn" id="2_jbny0"]
|
||||||
[ext_resource type="PackedScene" uid="uid://deyfeiqyi0wmj" path="res://scenes/player/shotgun.tscn" id="2_kknoo"]
|
[ext_resource type="PackedScene" uid="uid://deyfeiqyi0wmj" path="res://scenes/player/shotgun.tscn" id="2_kknoo"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cbvxh8xp8ilac" path="res://assets/Soldier.png" id="5_hjbn3"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3lfhi"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
albedo_texture = ExtResource("5_hjbn3")
|
||||||
|
texture_filter = 0
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_a50o4"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_a50o4"]
|
||||||
animation = &"Soldier|StrafeLeft"
|
animation = &"Soldier|StrafeLeft"
|
||||||
@ -45,10 +51,11 @@ nodes/Movement/node = SubResource("AnimationNodeBlendSpace2D_tt88r")
|
|||||||
nodes/Movement/position = Vector2(350, 90)
|
nodes/Movement/position = Vector2(350, 90)
|
||||||
node_connections = [&"output", 0, &"Movement"]
|
node_connections = [&"output", 0, &"Movement"]
|
||||||
|
|
||||||
[node name="soldier_m" type="SoldierMesh" unique_id=281995630 node_paths=PackedStringArray("hand_attachment", "animation_tree", "skeleton", "look_at", "hand_remover")]
|
[node name="soldier_m" type="SoldierMesh" unique_id=281995630 node_paths=PackedStringArray("hand_attachment", "animation_tree", "skeleton", "mesh", "look_at", "hand_remover")]
|
||||||
hand_attachment = NodePath("bone_attachment_3d/hand")
|
hand_attachment = NodePath("bone_attachment_3d/hand")
|
||||||
animation_tree = NodePath("animation_tree")
|
animation_tree = NodePath("animation_tree")
|
||||||
skeleton = NodePath("SoldierM/Soldier/Skeleton3D")
|
skeleton = NodePath("SoldierM/Soldier/Skeleton3D")
|
||||||
|
mesh = NodePath("SoldierM/Soldier/Skeleton3D/Soldier_Male_Mesh")
|
||||||
raygun = ExtResource("1_a50o4")
|
raygun = ExtResource("1_a50o4")
|
||||||
shotgun = ExtResource("2_kknoo")
|
shotgun = ExtResource("2_kknoo")
|
||||||
ball = ExtResource("2_jbny0")
|
ball = ExtResource("2_jbny0")
|
||||||
@ -60,10 +67,10 @@ hand_remover = NodePath("SoldierM/Soldier/Skeleton3D/player_hand_remover")
|
|||||||
[node name="Skeleton3D" parent="SoldierM/Soldier" parent_id_path=PackedInt32Array(1868587353, 1101404322) index="0" unique_id=1074852808]
|
[node name="Skeleton3D" parent="SoldierM/Soldier" parent_id_path=PackedInt32Array(1868587353, 1101404322) index="0" unique_id=1074852808]
|
||||||
bones/0/position = Vector3(0, 0, 0.00071418716)
|
bones/0/position = Vector3(0, 0, 0.00071418716)
|
||||||
bones/1/position = Vector3(0, 0, -0.007)
|
bones/1/position = Vector3(0, 0, -0.007)
|
||||||
bones/1/rotation = Quaternion(0.69334954, 0, 0, 0.7206015)
|
bones/1/rotation = Quaternion(0.707061, 0, 0, 0.70715255)
|
||||||
bones/1/scale = Vector3(1, 1, 1)
|
bones/1/scale = Vector3(1, 1, 1)
|
||||||
bones/2/position = Vector3(0.002, 3.469447e-18, -1.4901118e-10)
|
bones/2/position = Vector3(0.002, 3.469447e-18, -1.4901118e-10)
|
||||||
bones/2/rotation = Quaternion(0.9452424, 2.1415062e-08, 2.3228734e-08, -0.32636914)
|
bones/2/rotation = Quaternion(0.9515771, 2.0946482e-08, 2.3652152e-08, -0.30741027)
|
||||||
bones/2/scale = Vector3(1, 1, 1)
|
bones/2/scale = Vector3(1, 1, 1)
|
||||||
bones/3/position = Vector3(0, 0.0069999984, 5.169879e-25)
|
bones/3/position = Vector3(0, 0.0069999984, 5.169879e-25)
|
||||||
bones/3/scale = Vector3(1, 0.99999994, 1)
|
bones/3/scale = Vector3(1, 0.99999994, 1)
|
||||||
@ -71,7 +78,7 @@ bones/4/position = Vector3(-2.39752e-11, 0.010049875, -1.4156722e-10)
|
|||||||
bones/4/rotation = Quaternion(0.73982674, -2.6881349e-08, 7.0005948e-09, 0.67279744)
|
bones/4/rotation = Quaternion(0.73982674, -2.6881349e-08, 7.0005948e-09, 0.67279744)
|
||||||
bones/4/scale = Vector3(1, 0.99999994, 0.99999994)
|
bones/4/scale = Vector3(1, 0.99999994, 0.99999994)
|
||||||
bones/6/position = Vector3(-0.002, 3.469447e-18, -1.4901205e-10)
|
bones/6/position = Vector3(-0.002, 3.469447e-18, -1.4901205e-10)
|
||||||
bones/6/rotation = Quaternion(0.99965096, 1.8159414e-08, 1.8669416e-08, 0.026421284)
|
bones/6/rotation = Quaternion(0.99906224, 1.784155e-08, 1.8973411e-08, 0.043298792)
|
||||||
bones/6/scale = Vector3(1, 1, 1)
|
bones/6/scale = Vector3(1, 1, 1)
|
||||||
bones/7/position = Vector3(0, 0.0069999984, -5.169879e-25)
|
bones/7/position = Vector3(0, 0.0069999984, -5.169879e-25)
|
||||||
bones/7/rotation = Quaternion(-0.21973656, 4.264305e-08, 9.604991e-09, 0.9755593)
|
bones/7/rotation = Quaternion(-0.21973656, 4.264305e-08, 9.604991e-09, 0.9755593)
|
||||||
@ -80,33 +87,33 @@ bones/8/position = Vector3(-2.3975525e-11, 0.010049875, -4.6138777e-11)
|
|||||||
bones/8/rotation = Quaternion(0.86758894, -7.867721e-09, 3.036851e-08, 0.4972821)
|
bones/8/rotation = Quaternion(0.86758894, -7.867721e-09, 3.036851e-08, 0.4972821)
|
||||||
bones/8/scale = Vector3(1, 0.99999994, 0.99999994)
|
bones/8/scale = Vector3(1, 0.99999994, 0.99999994)
|
||||||
bones/10/position = Vector3(0, 0.009, 0)
|
bones/10/position = Vector3(0, 0.009, 0)
|
||||||
bones/10/rotation = Quaternion(-0.15285766, -0.13164644, 0.019584488, 0.97924477)
|
bones/10/rotation = Quaternion(-0.17217702, -0.13130672, 0.022171758, 0.9760237)
|
||||||
bones/10/scale = Vector3(1, 1, 1)
|
bones/10/scale = Vector3(1, 1, 1)
|
||||||
bones/11/position = Vector3(6.8186457e-17, 0.008, 0.001)
|
bones/11/position = Vector3(6.8186457e-17, 0.008, 0.001)
|
||||||
bones/11/rotation = Quaternion(0.06447923, 0.00012945535, -0.017645404, 0.99776304)
|
bones/11/rotation = Quaternion(5.6336947e-05, 1.1336415e-07, -1.5418686e-05, 1)
|
||||||
bones/11/scale = Vector3(1, 1, 1)
|
bones/11/scale = Vector3(1, 1, 1)
|
||||||
bones/12/position = Vector3(-2.2285185e-16, 0.0035, 0.0015000002)
|
bones/12/position = Vector3(-2.2285185e-16, 0.0035, 0.0015000002)
|
||||||
bones/12/rotation = Quaternion(-0.70710677, 0, 0, 0.70710677)
|
bones/12/rotation = Quaternion(-0.70710677, 0, 0, 0.70710677)
|
||||||
bones/12/scale = Vector3(1, 1, 1)
|
bones/12/scale = Vector3(1, 1, 1)
|
||||||
bones/14/position = Vector3(0.005, 0.005, -1.7336413e-21)
|
bones/14/position = Vector3(0.005, 0.005, -1.7336413e-21)
|
||||||
bones/14/rotation = Quaternion(0.8961431, 0.033815596, 0.4309325, -0.10040586)
|
bones/14/rotation = Quaternion(0.8812731, 0.032443736, 0.4378821, -0.17482696)
|
||||||
bones/14/scale = Vector3(1, 0.99999994, 1)
|
bones/14/scale = Vector3(1, 0.99999994, 1)
|
||||||
bones/15/position = Vector3(-1.3005262e-15, 0.0050000004, -6.938894e-18)
|
bones/15/position = Vector3(-1.3005262e-15, 0.0050000004, -6.938894e-18)
|
||||||
bones/15/rotation = Quaternion(1.0371065e-08, -6.748545e-09, 0.93159807, 0.36349007)
|
bones/15/rotation = Quaternion(1.0136929e-08, -7.095393e-09, 0.9187736, 0.3947851)
|
||||||
bones/15/scale = Vector3(1, 1, 1)
|
bones/15/scale = Vector3(1, 1, 1)
|
||||||
bones/16/position = Vector3(7.632945e-11, 0.007071071, 6.938894e-18)
|
bones/16/position = Vector3(7.632945e-11, 0.007071071, 6.938894e-18)
|
||||||
bones/16/rotation = Quaternion(0.0037297043, -0.10077756, -0.18467139, 0.9776127)
|
bones/16/rotation = Quaternion(0.029925434, -0.03646163, -0.18585494, 0.98144436)
|
||||||
bones/16/scale = Vector3(0.99999994, 0.9999999, 1)
|
bones/16/scale = Vector3(0.99999994, 0.9999999, 1)
|
||||||
bones/18/position = Vector3(-0.005, 0.005, -1.7303326e-21)
|
bones/18/position = Vector3(-0.005, 0.005, -1.7303326e-21)
|
||||||
bones/18/rotation = Quaternion(0.6575139, 0.16474941, -0.13285781, -0.7231058)
|
bones/18/rotation = Quaternion(0.64453954, 0.21452981, -0.0943058, -0.72777206)
|
||||||
bones/18/scale = Vector3(1, 0.99999994, 1)
|
bones/18/scale = Vector3(1, 0.99999994, 1)
|
||||||
bones/19/position = Vector3(-1.3005262e-15, 0.0050000004, -6.938894e-18)
|
bones/19/position = Vector3(-1.3005262e-15, 0.0050000004, -6.938894e-18)
|
||||||
bones/19/rotation = Quaternion(-2.1580865e-08, -3.5348958e-08, -0.27716652, 0.960822)
|
bones/19/rotation = Quaternion(-1.7099223e-08, -3.7721332e-08, -0.15766992, 0.98749197)
|
||||||
bones/19/scale = Vector3(1, 1, 1)
|
bones/19/scale = Vector3(1, 1, 1)
|
||||||
bones/20/position = Vector3(-2.2286711e-10, 0.007071072, 0)
|
bones/20/position = Vector3(-2.2286711e-10, 0.007071072, 0)
|
||||||
bones/20/rotation = Quaternion(-0.10948259, -0.47254592, -0.13016704, 0.8647373)
|
bones/20/rotation = Quaternion(-0.14211333, -0.45638156, -0.17767368, 0.8602045)
|
||||||
bones/20/scale = Vector3(1, 0.9999999, 1)
|
bones/20/scale = Vector3(1, 0.9999999, 1)
|
||||||
bones/22/position = Vector3(0.010810219, -0.0085772155, 0.0026520095)
|
bones/22/position = Vector3(0.012581623, -0.0085772155, 0.0021672463)
|
||||||
bones/22/rotation = Quaternion(3.090862e-08, 0.70710677, 0.70710677, 3.090862e-08)
|
bones/22/rotation = Quaternion(3.090862e-08, 0.70710677, 0.70710677, 3.090862e-08)
|
||||||
bones/22/scale = Vector3(1, 1, 1)
|
bones/22/scale = Vector3(1, 1, 1)
|
||||||
bones/24/position = Vector3(-0.011000002, 0.0050000013, 0.0070000007)
|
bones/24/position = Vector3(-0.011000002, 0.0050000013, 0.0070000007)
|
||||||
@ -125,6 +132,9 @@ bones/34/scale = Vector3(1, 1, 1)
|
|||||||
bones/36/position = Vector3(-0.002, -0.00568604, -0.02264523)
|
bones/36/position = Vector3(-0.002, -0.00568604, -0.02264523)
|
||||||
bones/36/rotation = Quaternion(0, 0, 0, 1)
|
bones/36/rotation = Quaternion(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="Soldier_Male_Mesh" parent="SoldierM/Soldier/Skeleton3D" index="0" unique_id=1117347105]
|
||||||
|
surface_material_override/0 = SubResource("StandardMaterial3D_3lfhi")
|
||||||
|
|
||||||
[node name="look_at_modifier_3d" type="LookAtModifier3D" parent="SoldierM/Soldier/Skeleton3D" index="1" unique_id=1054155740]
|
[node name="look_at_modifier_3d" type="LookAtModifier3D" parent="SoldierM/Soldier/Skeleton3D" index="1" unique_id=1054155740]
|
||||||
target_node = NodePath("../../../../look_at_root/look_at")
|
target_node = NodePath("../../../../look_at_root/look_at")
|
||||||
bone_name = "HEAD"
|
bone_name = "HEAD"
|
||||||
@ -158,7 +168,7 @@ origin_external_node = NodePath("../../../../look_at_root")
|
|||||||
transform = Transform3D(1, -2.2737368e-13, 0, 2.2737368e-13, 1, 0, -1.3552527e-20, 0, 1, 0, 0, 0)
|
transform = Transform3D(1, -2.2737368e-13, 0, 2.2737368e-13, 1, 0, -1.3552527e-20, 0, 1, 0, 0, 0)
|
||||||
|
|
||||||
[node name="bone_attachment_3d" type="BoneAttachment3D" parent="." unique_id=1964353847]
|
[node name="bone_attachment_3d" type="BoneAttachment3D" parent="." unique_id=1964353847]
|
||||||
transform = Transform3D(-35.57116, 3.7920692, -93.38263, -83.207954, 44.21317, 33.490837, 42.55741, 89.61482, -12.571805, -0.4719007, 3.3932352, 0.7389869)
|
transform = Transform3D(-31.442406, 3.474139, -94.86467, -87.30682, 38.17428, 30.335432, 37.26781, 92.36152, -8.969748, -0.47997, 3.3490868, 0.74448436)
|
||||||
bone_name = "HAND.R_end"
|
bone_name = "HAND.R_end"
|
||||||
bone_idx = 17
|
bone_idx = 17
|
||||||
use_external_skeleton = true
|
use_external_skeleton = true
|
||||||
|
|||||||
@ -401,6 +401,15 @@ impl ICharacterBody3D for LocalPlayer {
|
|||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(game) = Game::singleton()
|
||||||
|
&& let Some(player) = game.bind().find_player(s.player_id.unwrap_or(0))
|
||||||
|
&& let Some(team) = game.bind().get_team(player.data.team)
|
||||||
|
{
|
||||||
|
if let Some(mesh) = &mut s.soldier_mesh {
|
||||||
|
mesh.bind_mut().set_color(team.bind().color);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -308,6 +308,10 @@ impl ICharacterBody3D for RemotePlayer {
|
|||||||
name_label.set_text(&s.player_name);
|
name_label.set_text(&s.player_name);
|
||||||
name_label.set_modulate(s.player_color);
|
name_label.set_modulate(s.player_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(mesh) = &mut s.soldier_mesh {
|
||||||
|
mesh.bind_mut().set_color(s.player_color);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.swap_weapon(WeaponType::Raygun, false);
|
self.swap_weapon(WeaponType::Raygun, false);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use godot::{
|
use godot::{
|
||||||
classes::{AnimationTree, Skeleton3D},
|
classes::{AnimationTree, MeshInstance3D, Skeleton3D},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -18,6 +18,8 @@ pub struct SoldierMesh {
|
|||||||
#[export]
|
#[export]
|
||||||
skeleton: Option<Gd<Skeleton3D>>,
|
skeleton: Option<Gd<Skeleton3D>>,
|
||||||
#[export]
|
#[export]
|
||||||
|
mesh: Option<Gd<MeshInstance3D>>,
|
||||||
|
#[export]
|
||||||
pub raygun: Option<Gd<PackedScene>>,
|
pub raygun: Option<Gd<PackedScene>>,
|
||||||
#[export]
|
#[export]
|
||||||
pub shotgun: Option<Gd<PackedScene>>,
|
pub shotgun: Option<Gd<PackedScene>>,
|
||||||
@ -106,4 +108,12 @@ impl SoldierMesh {
|
|||||||
pub fn take_weapon(&self) -> Option<&DynGd<Node3D, dyn Weapon>> {
|
pub fn take_weapon(&self) -> Option<&DynGd<Node3D, dyn Weapon>> {
|
||||||
self.current_weapon.as_ref().take()
|
self.current_weapon.as_ref().take()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_color(&mut self, color: Color) {
|
||||||
|
if let Some(mesh) = &mut self.mesh
|
||||||
|
&& let Some(mut mat) = mesh.get_surface_override_material(0)
|
||||||
|
{
|
||||||
|
mat.set("albedo_color", &color.to_variant());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user