Killcam

So I saw this job (https://scriptfodder.com/jobs/view/2754) on Scriptfodder where the guy requested a Call of Duty-like killcam for Garry’s Mod and some people in the comments saying that it wasn’t possible or would cause too much lag, this interested me so I sorta took it as a challenge to try to make functional killcam. Also I believe this is the first killcam addon that actually tries to simulate the player’s death instead of doing a freeze cam or something similar.

Its basically entity tracking on the server and prediction on the client. When a player fires it saves data about the position, weapon used, angle, and gun sound then when another player dies it checks if their killer had fired a shot recently and if so, sends the killcam data to the client. On the client we just create 3 ClientsideModels and LerpVector them using the data from the server along with a HUDPaint and CalcView hook to make things look real fancy! This addon should work without a problem on any gamemode that doesn’t override GM:PlayerDeathThink with the exception of TTT because I added a fix in for that.

http://cloud-4.steamusercontent.com/ugc/35241247223644508/7FBAC09D6682C47F31417339E3B35E49EC23A228/

Workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=414973286
Github: https://github.com/Exho1/killcam

:confused:


[ERROR] lua/autorun/killcam.lua:229: attempt to index global 'GM' (a nil value)
  1. fn - lua/autorun/killcam.lua:229
   2. unknown - addons/ulib/lua/ulib/shared/hook.lua:179


Ah, what would we do without you Exho? :slight_smile:

did you dev in singleplayer u silly goose

Yes… I’ll change it to GAMEMODE

Fixed some issues and added a Github if anyone wants to look through the code

Dude,i love you.

I love you too internet stranger

I really like how you told us briefly how the killcam was achieved. People don’t do that much, and someone who wondered how it was possible, you made my life easier so I didn’t have to read the data from the files.

Great addon! C:

Tried this on my server today. Didn’t really work but it was a fun experience :smiley:

Thanks! I like explaining code for whatever reason, its just interesting

[editline]29th March 2015[/editline]

If you tell me what they are I can try to fix em

Looks pretty neat, was going to attempt something like this for a Gamemode but thought It was a little advanced for my liking, Good job.

I remember when you first signed up. You have come a long way and are a good contribution to the GMod community, we need more people like you. Keep up the good work.

Man that means a lot, it wasn’t that long ago when I was downloading the TTT equipment you posted on here. Thanks

Yeah Exho I’ve been following you for a while now and I really like your stuff

I might take your TV when you’re out one day, hope you don’t mind :v:

Was running the addon TTT server (heavily modded so probably conflicts with a lot of things).
Didn’t write anything down, just saying what I can remember from memory.

Notable Bugs:
At the end of a round, there would often be more than 1 “round winning kill” since I have ttt_postround_dm set to 1 in my config.
Sometimes the player models from “round winning kills” would stay after the round had ended, along with the bullet entity.
Bullet paths were often inaccurate or sometimes missed the player completely.
Often the bullets would appear even though the player was not killed with a gun.

That’s pretty much all I can remember. Hope this helps and good luck!!!

  1. Yeah I kinda figured that would happen, I might disable round winning kill because hooking onto TTTEndRound gets called too slow sometimes.
  2. That is likely caused by #1 because the models are a local variable and so if another killcam runs on top of the first (which shouldnt even happen) it could leave the models without any lua references to remove.
  3. Hey, clientside prediction isn’t 100% accurate. I have the shooting position and the angle so I just send the bullet that way.
  4. Yeah I noticed that too with some other weapons

nice job, looking forward for more work :slight_smile:

[editline]31st March 2015[/editline]

Idea:
Add support for pitch, volume, etc for the weapon sounds. I wouldnt be surprised if some people have weapons with a sound with higher/lower pitch or volume

I just released an update with proper clientside model posing after a bit of figuring out how TTT’s visualizer did it. So now the models should hopefully assume the position of holding a gun or what not when they died instead of being a t-pose

Also: http://forum.facepunch.com/showthread.php?t=1384927 :v: