aboutsummaryrefslogtreecommitdiffstats
path: root/code/pawn
diff options
context:
space:
mode:
Diffstat (limited to 'code/pawn')
-rw-r--r--code/pawn/Player.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/code/pawn/Player.cs b/code/pawn/Player.cs
index 1d87d94..7073bb1 100644
--- a/code/pawn/Player.cs
+++ b/code/pawn/Player.cs
@@ -60,6 +60,8 @@ public partial class Player : AnimatedEntity
[Net, Predicted]
public TimeSince TimeSinceDeath { get; set; } = 0;
+ public Player LookingAt { get; set; }
+
public override void Spawn()
{
SetModel( "models/citizen/citizen.vmdl" );
@@ -189,6 +191,29 @@ public partial class Player : AnimatedEntity
Components.Create<SpectatorCameraComponent>();
}
+ if ( Game.IsClient )
+ {
+ var start = AimRay.Position;
+ var end = AimRay.Position + AimRay.Forward * 5000;
+
+ var trace = Trace.Ray( start, end )
+ .UseHitboxes()
+ .WithAnyTags( "solid", "livingplayer" )
+ .Ignore( this )
+ .Size( 1f );
+
+ var tr = trace.Run();
+ if ( tr.Hit && tr.Entity.IsValid() && tr.Entity is Player player )
+ {
+ LookingAt = player;
+ }
+ else
+ {
+ LookingAt = null;
+ }
+ }
+
+
}
public override void BuildInput()