Community > Fixed Bugs

Cars spawn in walls (Montgomery and LS Hospital)

(1/1)

Hank_Montgomery:
1:41 in Montgomery
1:49 near County General Hospital (LS)

Goldenman:
have you reproduced this issue multiple times?

Hank_Montgomery:

--- Quote from: GoldenBoy on March 31, 2023, 08:05:12 am ---have you reproduced this issue multiple times?

--- End quote ---
Tried to, but they keep spawning on the roads

ARSHIA:
In some places like the gas station near Angel Pine and Bayside as well, In shack columns for example.

Mike:
I've improved this in 1.15. It's already pretty good at preventing vehicles spawning inside buildings adjacent to the spawn nodes, however I have now also added line-of-sight collision checks to prevent them spawning inside smaller walls/objects like this.

It will never be perfect but you should see the failure rate massively drop now.

The obstruction testing code has gotten more complex than I thought it ever would lol, here's an inside look at some of the logic (if you can understand wtf is going on congrats):


The logic for the entire vehicle spawning system is something along the lines of:
- Get the node nearest the player.
- If it's too far away (200m, increased to 250m in 1.15), abort.
- If it's near enough, find a node a bit of a distance away (so vehicles don't spawn at players' feet). This is in a random direction but always the same distance (about 300m I think).
- If that's too far away or the height difference is too much, revert back to the node closest to the player.
  - This is to prevent vehicles spawning in underground parking lots, up on bridges etc.).
- If the selected node is an intersection, select an adjacent node (we don't want to spawn vehicles in the middle of an intersection, plus it makes the next step easier).
- From the now selected node, select an adjacent node and work out the road direction based on those two nodes (so vehicles spawn parallel to the road).
- Test the right hand side for obstruction (height difference, collision, other vehicle exists there).
- If that fails, test the left side the same way.
- If that also fails, use the middle of the road, but we also test if a vehicle exists there and if so we abort.

There's probably some other checks that I forget about, but yeah, it's a relatively complex set of checks and rules to try and spawn vehicles in a suitable place and a suitable distance away... it's not just 'pick a random place and hope for the best'.

It's also code I wrote many years ago and keep bolting things onto, so it's kinda like a house of cards held up by hope and wishes right now. I shoud probably rewrite it...

Navigation

[0] Message Index

Go to full version