• How could I add knockback?
    6 replies, posted
Is it possible to make a SWep that moves back the player everytime it fires? I'm not talking about recoil and spray patterns. Just a gun with enough force to push yourself opposite of where the gun is pointed. It would allow you to bridge gaps by jumping and shooting at the floor. Is there any way to do this?
In WEAPON/PrimaryAttack, use Entity/SetVelocity or PhysObj/SetVelocity on the player using the weapon (self.Owner)
so something like: self.Owner:SetVelocity( Vector( -1 * EyeVector() ) )
Pretty much, but instead of EyeVector, use self.Owner:EyeAngles():Forward(), so maybe like this: function SWEP:PrimaryAttack() self:EmitSound( "Weapon_357.Single" ) self:ShootBullet( 1000, 1, 0 ) self.Owner:ViewPunch( Angle( -10, 0, 0 ) ) if ( !SERVER ) then return end local forward = self.Owner:EyeAngles():Forward() self.Owner:SetVelocity( forward * -1000 ) end (Code formatting doesn't work any more )
thanks is there anything I could for you? (besides donate, I'm broke)
what no lol
FYI You can update the player velocity for the current frame using "PhysObj/SetVelocity" or for the next frames also using "SetVelocityInstantaneous"
Sorry, you need to Log In to post a reply to this thread.