garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

Entity.SetFriction has no effect for players

Open disseminate opened this issue 9 years ago • 4 comments

Currently Entity.SetFriction sets the keyvalue "m_flFriction" which is great for props or other entities that rely on this keyvalue. It has no effect on players.

Player friction is set in engine via pEnt->SetFriction( float multiplier ) instead. Adding a IsPlayer() check for this would solve it.

disseminate avatar Aug 04 '14 17:08 disseminate

Bonus points if you add/un-ifdef the func_friction/CFrictionModifier entity back in!

disseminate avatar Aug 04 '14 17:08 disseminate

Get/SetFriction would have to be shared for players and network any updates to the client since player movement is done shared. Other than that, adding friction support to player movement is pretty easy - GetFriction just has to be factored into these lines:

  • https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/shared/gamemovement.cpp#L1426
  • https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/shared/gamemovement.cpp#L1630
  • https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/shared/gamemovement.cpp#L2225
  • https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/shared/gamemovement.cpp#L2304

Kefta avatar Jul 31 '18 21:07 Kefta

bump this would be useful for many players including myself looks easy to implement too

Andrew-Eathan avatar Oct 28 '21 11:10 Andrew-Eathan

This has been an issue for too long. Please fix. I would like to be able to set the friction of players when they are shot by a gun, but it is currently not possible. This would make for a great equipment item in TTT for traitors to slow down people. @svdm

colemclaren avatar Aug 03 '22 02:08 colemclaren

SetFriction now affects player movement, as a multiplier of sv_friction convar's value, in range of [0,10].

robotboy655 avatar Jun 27 '23 19:06 robotboy655

Thanks I got engaged and bought a house and divorced and moved continents and moved back and did it again but it was worth it

disseminate avatar Jun 27 '23 19:06 disseminate