• LookupSequence / SetSequence Seemingly Being Skipped
    3 replies, posted
My problem is that the animation I specify in the script in my lua/autorun folder doesn't get used, while the offset does. I can't figure it out why it suddenly stopped working. [lua] local veh = nil local isScarSeat = nil local SCar = nil local plyAng = nil local vehAng = nil local function SCarOverrideTurretAnim( ply ) --Checking if the player is in a vehicle if ply:InVehicle() then //Msg("Checked In Vehicle\n") --Getting the vehicle veh = ply:GetVehicle() --Is the vehicle a seat in a SCar? isScarSeat = veh:GetNetworkedInt( "SCarSeat" ) --Getting the SCar SCar = veh:GetNetworkedEntity("SCarEnt") --Checking if it's passenger seat 2 and if it's a seat that should use the turret animation if isScarSeat == 2 and veh:GetNetworkedBool("IsTurretSeat") then //Msg("Checked Seat 2\n") --Compensating for the position offset the animation will add ply:SetLocalPos( Vector(-9,0,-20) ) --Making the player face the direction of the turret. --Getting the angle from the turret plyAng = SCar:GetNetworkedEntity( "JeepTurret" ):GetAngles() --Getting the angle from the vehicle vehAng = SCar:GetAngles() --Use the vehicles pitch plyAng.p = vehAng.p --Use the vehicles roll plyAng.r = vehAng.r --You may have to adjust an offset later with your man_gun animation. Just replace SOME_OFFSET with the degrees you need. plyAng.y = vehAng.y --+ SOME_OFFSET --ply:SetAngles( plyAng ) ply:SetAngles( plyAng ) --//Overriding the animation here --ply.CalcSeqOverride = ply:LookupSequence( "Man_gun" ) --ply.CalcSeqOverride = ply:LookupSequence( ACT_HL2MP_IDLE_DUEL ) --ply.CalcSeqOverride = ply:LookupSequence( "idle_dual" ) --ply.CalcSeqOverride = ply:LookupSequence( "1745" ) --ply:SetSequence( ply.CalcSeqOverride ) ply:DoAnimationEvent( ACT_HL2MP_IDLE_DUEL ) return true end end end hook.Add("UpdateAnimation", "SCarOverrideTurretAnim", SCarOverrideTurretAnim)[/lua] I checked the wikis and the syntax is correct; it also gives no errors when used. Does anyone have any idea what's wrong with it? Edit: Using DoAnimationEvent instead of the Lookup/SetSequence method worked fine.
SetSequence is being overriden each frame by other Animation hooks. [editline]10th November 2013[/editline] Also, saving local variables outside of the function is a bad idea.
[QUOTE=Robotboy655;42819167]SetSequence is being overriden each frame by other Animation hooks. [editline]10th November 2013[/editline] Also, saving local variables outside of the function is a bad idea.[/QUOTE] Which hooks? I need to know which ones to override.
All of them that are called from CalcMainActivity: [url]https://github.com/garrynewman/garrysmod/blob/ff51a59d5a821dec3c8f524631c86150b3e4744d/garrysmod/gamemodes/base/gamemode/animations.lua[/url] ProTip: You can search GMods source code like this: [url]https://github.com/garrynewman/garrysmod/search?q=UpdateAnimation&ref=cmdform[/url]
Sorry, you need to Log In to post a reply to this thread.