Physics materials control how surfaces behave in your Midtown Madness map - from sticky asphalt to slippery ice. This guide covers customizing physics properties for your custom city.
- Basic Physics Setup
- Creating Material Constants
- Using Materials in Polygons
- Understanding Parameters
- Common Material Types
- Troubleshooting
- Tips & Best Practices
Physics materials are defined in src/USER/physics.py. You can customize existing material indices (94-98 are available for custom use):
custom_physics = {
97: {"friction": 1.5, "elasticity": 0.10, "drag": 0.0}, # High-grip surface
98: {"friction": 0.1, "elasticity": 0.10, "drag": 0.0} # Slippery surface
}The index number (97, 98) corresponds to the physics material slot you're customizing.
After defining your physics materials, create constants in src/constants/file_formats.py:
class Material:
DEFAULT = 0
GRASS = 87
WATER = 91
RACE_TRACK = 97 # Your custom material at index 97
ICE = 98 # Your custom material at index 98This allows you to reference your materials by name instead of remembering index numbers.
Reference your custom materials when creating polygons:
# High-grip race track section
create_polygon(
bound_number = 100,
material_index = Material.RACE_TRACK, # References index 97
vertex_coordinates = [
(0.0, 0.0, 0.0),
(50.0, 0.0, 0.0),
(50.0, 0.0, 20.0),
(0.0, 0.0, 20.0)
]
)
# Slippery ice patch
create_polygon(
bound_number = 101,
material_index = Material.ICE, # References index 98
vertex_coordinates = [
(60.0, 0.0, 0.0),
(80.0, 0.0, 0.0),
(80.0, 0.0, 20.0),
(60.0, 0.0, 20.0)
]
)Workflow:
- Define physics properties in
src/USER/physics.pywith an index (94-98) - Add a constant to
Materialclass insrc/constants/file_formats.py - Use the constant name in your
create_polygon()calls
friction: Surface grip (higher = more traction)
"friction": 2.0 # High grip (race track)
"friction": 1.0 # Normal road (vanilla default)
"friction": 0.68 # Grass (vanilla)
"friction": 0.1 # Ice/very slipperyNote: the parameters below need more testing
bump_height + bump_width: Surface roughness
# Smooth (default)
"bump_height": 0.0, "bump_width": 0.05
# Grass (vanilla)
"bump_height": 0.20, "bump_width": 5.0
# Sidewalk (vanilla)
"bump_height": 0.20, "bump_width": 2.0type: Surface category
"type": 0 # Default (roads, buildings)
"type": 1 # Sidewalk/pedestrian
"type": 2 # Grass/natural terrainsound: Audio feedback
"sound": 0 # Road sound
"sound": 1 # Sidewalk/concrete
"sound": 2 # Grass/dirtsink_depth: How deep vehicles sink
"sink_depth": 1.0 # Normal (default)
"sink_depth": 0.5 # Partial sinking (mud)
"sink_depth": 0.0 # No sinking (water)Based on analysis of vanilla materials, these are either unused or always constant:
elasticity: Always 0.10 in vanilla (changing may cause issues)drag: Always 0.0 in vanilla (appears unused)bump_depth: Always 0.0 in vanilla (appears unused)velocity: NOT USED by the gameptx_color: Always (1.0, 1.0, 1.0) in vanilla
Each example shows both the physics definition and Material constant.
# In src/USER/physics.py
custom_physics = {
94: {
"friction": 1.5,
"elasticity": 0.10,
"drag": 0.0
}
}
# In src/constants/file_formats.py
class Material:
RACE_TRACK = 94# In src/USER/physics.py
custom_physics = {
95: {
"friction": 0.1,
"elasticity": 0.10,
"drag": 0.0
}
}
# In src/constants/file_formats.py
class Material:
ICE = 95# In src/USER/physics.py
custom_physics = {
96: {
"friction": 0.5,
"elasticity": 0.10,
"drag": 0.0,
"bump_height": 0.30,
"bump_width": 3.0,
"sink_depth": 0.5,
"type": 2,
"sound": 2
}
}
# In src/constants/file_formats.py
class Material:
MUD = 96# In src/USER/physics.py
custom_physics = {
97: {
"friction": 0.65,
"elasticity": 0.10,
"drag": 0.0,
"bump_height": 0.20,
"bump_width": 5.0,
"type": 2,
"sound": 2
}
}
# In src/constants/file_formats.py
class Material:
GRASS_CUSTOM = 97 # Note: GRASS = 87 already existsPhysics changes not appearing in-game:
- Check that
set_physics = Truein your settings - Verify you're using available indices (94-98)
- Ensure your polygon references the correct physics index
- Complete workflow: Always create both the physics definition AND the Material constant
- Available indices: Only 94-98 are available for custom physics
- Name your materials: Use descriptive constant names (ICE, MUD, etc.)
- Stick to vanilla patterns: Use
elasticity = 0.10, drag = 0.0unless experimenting - Focus on friction: This is the primary control for surface behavior
- Test incrementally: Change one parameter at a time
- Reference vanilla: Check indices 87 (grass) and 91 (water) for examples
- Debug mode: Enable
debug_physics = Trueto see all physics parameters
- Physics implementation:
src/file_formats/physics.py - Your custom physics:
src/USER/physics.py - Material constants:
src/constants/file_formats.py - Debug output:
debug/PHYSICS/PHYSICS_DB.txtwhen debug enabled