Friction additions
Moderator: GZDoom Developers
Friction additions
So. Friction. The default implementation has served Doom well for 20+ years.
Welcome to the 21st century. It's time to improve that.
Making a good kart racer needs a couple of additions to the friction system. We can get mostly there, but there's a couple of additions I'd like added so that we can push it to the next level and make a proper kart racer. I imagine these additions would be helpful for anyone looking to do advanced stuff with object movement as well.
The first addition is one that I can't seem to find whether it exists or not - an entry in MAPINFO/(default)map to modify the standard friction values. These would be normalFriction and lowFriction corresponding to the default friction value and the one applied to low-friction sectors. Sector_SetFriction (EDIT: and TERRAIN) is unaffected.
The second is an addition to actors to allow a friction value. This would default to 1.0. To find the total friction that should be applied to an actor, you multiply the friction of the surface you're on by the friction of the actor. As such, the default value preserves original behaviour.
I want to be able to modify an actor's friction level at runtime (say, for example, I apply the brakes to my kart, or I want to introduce friction when the kart is travelling in a different direction to where it's facing). Some corresponding ACS functions (GetActorFriction, SetActorFriction) would be required for this.
This addition would go a long way to making my life easier (as well as anyone wanting to implement vehicles in their own mods).
Welcome to the 21st century. It's time to improve that.
Making a good kart racer needs a couple of additions to the friction system. We can get mostly there, but there's a couple of additions I'd like added so that we can push it to the next level and make a proper kart racer. I imagine these additions would be helpful for anyone looking to do advanced stuff with object movement as well.
The first addition is one that I can't seem to find whether it exists or not - an entry in MAPINFO/(default)map to modify the standard friction values. These would be normalFriction and lowFriction corresponding to the default friction value and the one applied to low-friction sectors. Sector_SetFriction (EDIT: and TERRAIN) is unaffected.
The second is an addition to actors to allow a friction value. This would default to 1.0. To find the total friction that should be applied to an actor, you multiply the friction of the surface you're on by the friction of the actor. As such, the default value preserves original behaviour.
I want to be able to modify an actor's friction level at runtime (say, for example, I apply the brakes to my kart, or I want to introduce friction when the kart is travelling in a different direction to where it's facing). Some corresponding ACS functions (GetActorFriction, SetActorFriction) would be required for this.
This addition would go a long way to making my life easier (as well as anyone wanting to implement vehicles in their own mods).
Last edited by GooberMan on Tue Jul 15, 2014 7:55 am, edited 1 time in total.
- TheMightyHeracross
- Posts: 2100
- Joined: Sun Aug 18, 2013 9:41 am
- Location: Philadelphia, PA
Re: Friction additions
I'm in total support of this, it'd be useful outside of vehicles as well.
- NeuralStunner
-

- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Friction additions
For the latter feature, Get/SetActorProperty would probably be sufficient.
Re: Friction additions
Bump as we are now at the point where we need a response on this.
Re: Friction additions
Added per-actor friction multiplier. You can set it from DECORATE or with ACS (APROP_Friction = 42). However, the current implementation doesn't seem too friendly, as the range of useful values is very small (basically, between 0.95 and 1.1 or thereabouts). Should I center it around a different friction level than 0? The minimum friction you can normally set is actually 0xD001.
Thoughts?
Thoughts?
- Ed the Bat
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
- Contact:
Re: Friction additions
I hope I'm not out of line for asking, but I've pondered silently for a long time about something along the lines of this suggestion, but with a little bit of a twist...
In short, I have characters that I would like to be resilient against having their friction adjusted in either extreme. That is, I'd like them not to slide on slippery floors, but also not to be bogged down by high-friction terrain. But, knowing as little as I do, I was never sure if it could feasibly be done...
In short, I have characters that I would like to be resilient against having their friction adjusted in either extreme. That is, I'd like them not to slide on slippery floors, but also not to be bogged down by high-friction terrain. But, knowing as little as I do, I was never sure if it could feasibly be done...
Re: Friction additions
My intention for my use case is to set the normal and low friction values to 1.0 and manage friction through TERRAIN. I'd be using far higher friction values than the default, so the value set on the actors would have greater effect and a wider feasible range (although I will never set the actor's friction to be greater than 1). The script would be constantly altering that actor friction value as a result of traveling direction and the user applying brakes.randi wrote:Thoughts?
I'll have a better look at the change tonight, but I imagine the change will be more useful depending on the friction of the surface you're on.
Re: Friction additions
Will this finally make it possible to do non-slippery player movement without weird workarounds!? =D
Also, if this is usable on the player, what effects does it have on the weapon bobbing speed?
Also, if this is usable on the player, what effects does it have on the weapon bobbing speed?
Re: Friction additions
Alrighty, so as near as I can tell the terrain documentation is horrible. Experiments with the values (ie I haven't looked at the source code) lead me to believe that friction there is calculated as <base friction> + <friction delta> * ( <friction value> - 1.0 ), where <friction delta> is ( 1.0 - <base friction> ).
So with a default terrain friction of 2.0 and setting my actor's friction to 0.90625 I get the exact same behaviour as I would from normal Doom friction code.
Excellent.
I guess this means the lowest total friction, going by the 0xD001 value, would be equivalent to setting 0.812515 on the actor with a defaultterrain of 2.0.
So with a default terrain friction of 2.0 and setting my actor's friction to 0.90625 I get the exact same behaviour as I would from normal Doom friction code.
Excellent.
I guess this means the lowest total friction, going by the 0xD001 value, would be equivalent to setting 0.812515 on the actor with a defaultterrain of 2.0.
- Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Friction additions
Tell me about it. The implementation was bad in Boom and nothing has changed about it. BTW, I think the newly added factor is applied in the wrong place of the entire calculation.
- Caligari87
- Admin
- Posts: 6241
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Friction additions
It's been mentioned multiple times that one of the biggest issues in the source code is the obscure "black physics box". Since it's been determined that ZDoom's goal is to cater to a more modern experience and mod features, would it be worthwhile to re-write the physics engine to something better understood, that merely approximates the original Doom without being bound by it?

- Graf Zahl
- Lead GZDoom+Raze Developer

- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Friction additions
Count me out if that happens. That code is so full of quirks and idiosyncrasies that it's completely impossible. It's also not that hard to understand, it's just a really, really bad implementation of game physics. It's too bad that the game lives or dies with it.
As for friction, the code that applies friction to an actor is not that bad, just the way how Boom derives a friction value from the given parameter.
As for friction, the code that applies friction to an actor is not that bad, just the way how Boom derives a friction value from the given parameter.
