Project Zomboid

Project Zomboid

Unmaintained Vehicles
Revale08 7 月 27 日 上午 11:20
Vehicles Flipping on Re-render
Hey Noel, I ran your script through a couple of AI models (as im new to Zomboid modding scene) it may be total rubbish, but felt like id report here incase it is of any use to you.

GPT: Problem explained:

```
Potential Culprit: Missing or Partially Spawned Suspension/Wheels
If a vehicle spawns with suspension, brakes, or tires missing, or even with a condition of 0, and then goes offscreen:

PZ’s physics engine sometimes has a freak-out when that vehicle re-renders — it’s like the game "forgets" how to rest it properly.

This can result in vehicles spawning in mid-air slightly or clipping terrain, then falling or flipping when physics re-activate.

Especially if FullAssemblyDelete = true, and the mod decides to remove tire + brake + suspension, the car can look parked but act cursed when you come back later.

Suggestions:
Try disabling FullAssemblyDelete and instead just use the individual component chances. It gives more granular control and reduces the chance of truly unstable spawns.

Avoid setting chances too high for critical parts like tires, suspension, or brakes. No tires = wonky physics. No suspension = clown car flips.

Use UVDebugPrint = true to watch console logs when vehicles spawn. It’ll help catch what was removed and where.
```



Would any of these 'fixes' detract from the mods intended purpose?:

```
Would a physics-safety patch “detract” from the mod’s goal?
Not really. In fact, I'd argue it could enhance it.

Here's why:

The intention is visual and gameplay immersion — "oh no, this car’s screwed!" — not "oh no, this car is now airstriking my safehouse."

A patch that, say:

Forces a vehicle to rest on flat tires instead of none

Replaces ultra-critical missing parts like all four wheels with ruined versions

Or despawns vehicles entirely if they'd be unrenderable messes
...would just be ensuring PZ doesn’t nuke itself with its janky vehicle physics.

✅ Balanced Fix Ideas:
If you want to stay lore-friendly:

Post-spawn override:

Check if vehicle has zero suspension/brakes/tires → replace with condition 1 broken parts or deflated tires.

Fallback wheel logic:

If FullAssemblyDelete triggers total removal, instead of deleting the entire assembly, it:

Deletes the tire and brake, but sets suspension to 1 condition, so physics still anchor it.

Invisible "wheel stand" part:

If all else fails, attach a dummy invisible part just to stabilize physics. Not visible, but keeps the car grounded.```

Claude also went the same route.

```
Key Changes Made:
1. Never Remove Critical Physics Components

Tires, brakes, and suspension are never completely removed (setInventoryItem(nil))
Instead, they spawn with condition = 1 (extremely damaged but still present)

2. Enhanced Tire Handling

Severely damaged tires get minimal air (1 unit) instead of being removed
This maintains ground contact for physics calculations

3. Conservative Engine/Brake Degradation

Replaced the potentially problematic logarithmic formula with simple percentage reduction
Ensures conditions never go below 1 (which could cause physics issues)

4. Safe Assembly Damage System

FullAssemblyDelete mode now damages components instead of removing them
Maintains structural integrity while still providing the "unmaintained" experience

5. Better Error Prevention

Added more condition checks to prevent edge cases
More conservative mathematical operations

Benefits:

Maintains mod purpose: Vehicles still spawn in poor condition requiring repairs
Prevents physics glitches: All critical components remain present for stability
Gameplay impact preserved: Players still need to repair/replace damaged parts
Performance safe: No risk of vehicles moving/flipping when offscreen

User Experience:
Players will still encounter:

Nearly flat tires that need air and replacement
Extremely worn brakes that barely work
Damaged suspension affecting handling
All other non-critical part removals (mufflers, windows, etc.)

The vehicles will still feel "unmaintained" and require significant work, but won't cause the physics instability issues you were experiencing.
```
< >
正在显示第 1 - 9 条,共 9 条留言
Revale08 7 月 27 日 上午 11:57 
Quick follow up, ive implemented the changes, seems to atleast activate correctly without errors, initital spawned vehicles seem to all have wheels. Will attempt to play this a bit longer for thoroughness and report back if i suffer any flips etc.
Malu 7 月 27 日 下午 4:56 
It actually makes a lot of sense for the physics engine to spaz out in that case. I wonder if that will solve the issue.
Revale08 7 月 27 日 下午 5:44 
All signs seem good so far, i've got an unlisted version, but hesitant to share without the authors blessing :)
Noel  [开发者] 7 月 28 日 上午 1:09 
Hi, @Revale08 feel free to share it!
I am slowly trying to find a workaround, and I suspect that the problem rests in removing parts "under other parts" (not using full FullAssemblyDelete), tho more testing is required to confirm this. I'll try to update the mod till end of the week.

Tho any chance you could give me more details on when this issue happens (What vehicle, where it happened on map, how long it took.), and possibly provide save, I have a hard time replicating the issue. I would be very glad if you could help me with providing more information.

Also could you let me know on what type of disc (SSD/HDD etc.) on what you have Zomboid installed, as this could be caused by slow loading times / shutters.
最后由 Noel 编辑于; 7 月 28 日 上午 2:00
Revale08 7 月 28 日 上午 3:10 
https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=3536292786 I would just like to say this still has nowhere near the test time I’d like it to have had given I’m a Dad in the middle of 6 weeks school holidays, so my free time is limited to say the least. Also let me know whenever you want this deleting and I’ll happily oblige.

With regards to disk type, I’m actually playing on steam deck. Vehicle type, I can’t recall for certain, I think I remember a chevalier, but it’s definitely happened to multiple types, it seems to affect both cars I’ve driven and moved, and also cars I’ve yet to touch.

One more thing, this solution and code change was totally all the AI, I’ve not even looked at the code, as I’m used to other languages in other games(mainly space engineers) so if this contains any glaring errors blame Silicon Valley 😂.
最后由 Revale08 编辑于; 7 月 28 日 上午 3:29
Revale08 7 月 28 日 上午 3:11 
I hope your approach is the correct one, as the aesthetic of cars missing tyres is something I definitely miss :)
Revale08 7 月 28 日 上午 5:14 
I will attempt to construct a version that takes your Hierarchy aware approach. Will post here once done (Just have to choose a window when the child isn’t hogging the desktop lol)
最后由 Revale08 编辑于; 7 月 28 日 上午 5:41
Revale08 7 月 29 日 上午 7:44 
Update on the Physics Fix:

What I tried:

1. Hierarchy-aware coordination - attempted to ensure if suspension was removed, brakes+tires were also removed to maintain valid configurations. Failed due to Project Zomboid’s spawn order complexity and state management issues.
2. Retroactive removal system - tried having later-spawning parts remove already-spawned parts to fix hierarchy. Didn’t work - setInventoryItem(nil) appears ineffective on already-created parts.
3. Complex state tracking - multiple attempts at coordinating decisions across different Vehicles.Create functions. Created more problems than it solved.

Final solution:
Reverted to your original code structure but never remove brakes or suspension - instead set their condition to 1 (essentially broken but present). Only tires can be safely removed without physics issues.
Result: Same gameplay experience (broken parts need replacement), same visual appeal (missing tires), zero physics instability. Clean, simple code that respects PZ’s architecture.
The key insight: don’t fight the engine’s limitations - work within them.

I officially admit defeat lol. I’ll keep my fingers crossed for you :)

https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=3536292786
最后由 Revale08 编辑于; 7 月 29 日 上午 7:55
Revale08 7 月 31 日 下午 2:28 
Have Deleted my band aid Version due to your update. Thanks for the update :)
< >
正在显示第 1 - 9 条,共 9 条留言
每页显示数: 1530 50