Hi,
To preface, I'm still pretty new to Lua. I'm attempting to use the entity drive system to make a vehicle with proper prediction. The only real hitch I've run into so far is the animations that run on the player when driving a prop: in sandbox\gamemode\shared.lua there's a function called "PlayerDriveAnimate" which forces an animation sequence to play on the player, specifically ACT_HL2MP_IDLE_MAGIC, whenever said player "drives" an entity.
Is there any way to override this without modifying the function itself? I'd like to be able to use ACT_HL2MP_SIT or something similar instead.
GM/PlayerDriveAnimate
I found a solution, and I just wanted to update this thread with the answer in case anyone has the same problem.
PlayerAnimateDrive is a gamemode function, and in order to override gamemode functions you have to hook into them and return something. I just put false, and it works. You can also add whatever code you want to run in the function, so I made it use a sitting animation instead of the "idle magic" one it normally runs. This should probably be run as shared:
hook.Add("PlayerDriveAnimate", "ReplaceAnim", function( ply, vel )
local driving = ply:GetDrivingEntity()
if ( !IsValid( driving ) ) then return end
if ( driving ) then
ply:SetPlaybackRate( 1 )
ply:ResetSequence( ply:SelectWeightedSequence( ACT_HL2MP_SIT ) )
end
return false
end)
Sorry, you need to Log In to post a reply to this thread.