diff --git a/Assets/prefabs/player.prefab b/Assets/prefabs/player.prefab
index 2ca5ada..3040cb5 100644
--- a/Assets/prefabs/player.prefab
+++ b/Assets/prefabs/player.prefab
@@ -57,9 +57,9 @@
},
{
"__type": "AnimationHelper",
- "__guid": "536068a6-fe5d-4f45-af74-9522ebf7e663",
+ "__guid": "c5781f89-5808-4b4f-8971-343abe63b1da",
"BodyWeight": 1,
- "EyesWeight": 0,
+ "EyesWeight": 1,
"HeadWeight": 1,
"LookAtEnabled": true,
"Target": {
@@ -70,9 +70,9 @@
}
},
{
- "__type": "PlayerDresser",
- "__guid": "9e0e0634-d503-4286-ace6-a8b6f1303e94",
- "BodyRenderer": {
+ "__type": "FootSteps",
+ "__guid": "f6ee40f5-5541-4a85-bc06-259b451d0891",
+ "Source": {
"_type": "component",
"component_id": "4fd8c36d-180b-41af-8439-6b975ca1c7b3",
"go": "b99ceffc-a173-4a6e-a239-6d3c1612c09f",
diff --git a/Code/FootSteps.cs b/Code/FootSteps.cs
new file mode 100644
index 0000000..8073bbd
--- /dev/null
+++ b/Code/FootSteps.cs
@@ -0,0 +1,59 @@
+using Sandbox;
+using static Sandbox.VertexLayout;
+
+public sealed class FootSteps : Component
+{
+ [Property] SkinnedModelRenderer Source { get; set; }
+
+ protected override void OnEnabled()
+ {
+ if ( Source is null )
+ return;
+
+ Source.OnFootstepEvent += OnEvent;
+ }
+
+ protected override void OnDisabled()
+ {
+ if ( Source is null )
+ return;
+
+ Source.OnFootstepEvent -= OnEvent;
+ }
+
+ TimeSince timeSinceStep;
+
+ void OnEvent( SceneModel.FootstepEvent e )
+ {
+ if (IsProxy)
+ return;
+
+ if ( timeSinceStep < 0.2f )
+ return;
+
+ var tr = Scene.Trace
+ .Ray( e.Transform.Position + Vector3.Up * 20, e.Transform.Position + Vector3.Up * -20 )
+ .Run();
+
+ if ( !tr.Hit )
+ return;
+
+ if ( tr.Surface is null )
+ return;
+
+ timeSinceStep = 0;
+
+ var sound = e.FootId == 0 ? tr.Surface.Sounds.FootLeft : tr.Surface.Sounds.FootRight;
+ if ( sound is null ) return;
+
+ var position = tr.HitPosition + tr.Normal * 5;
+ BroadcastFootstep(sound, position, e.Volume);
+ }
+
+ [Broadcast]
+ void BroadcastFootstep(string sound, Vector3 position, float volume)
+ {
+ var handle = Sound.Play(sound, position);
+ handle.Volume *= volume;
+ }
+}
diff --git a/kakozuzo_2.sln.DotSettings.user b/kakozuzo_2.sln.DotSettings.user
index 4f29b3b..b69930c 100644
--- a/kakozuzo_2.sln.DotSettings.user
+++ b/kakozuzo_2.sln.DotSettings.user
@@ -2,4 +2,5 @@
True
True
ForceIncluded
+ ForceIncluded
\ No newline at end of file