Open AndyGura opened 4 months ago
Absolutely man! feel free to take it. Lately i've had very little time to work in this project. Last time I was trying to understand the AI driver part, but the decompiled code is a complete mess.
Thank you! I started integrating it and it works fantastically! Here is the video.
I have some questions though and feature requests, maybe you can write me an email to andygura@guraklgames.com so we can communicate? For now I have these:
carspecs.pbs
file (uncompressed), car never shifts to 2nd gear, is it an issue with the code or I do something wrong? I use pbs from TNFS SE (PC).player_car.matrix
include body roll and body pitch? It feels like it doesn't. Is there way to retrieve final rotation matrix with these included?xman
car? Will be great to be able to start race with 0, 1 or 7 opponents, just like in game.Hi Andy, that's awesome work, man! Merged your fixes (thanks!) and tweaked the AI a bit to include some traffic cars (now it's 1 player, 4 opponents and 3 traffic). Still very dumb AI, cars keep crashing on each other, as it has just the minimal functions to work.
Hi! Thank you, sounds great! I see now some cars start going backwards at some point, those are probably traffic cars. But I'm not sure how can I control how many racers and how many traffic cars I want to spawn? Also, is it possible to spawn/despawn traffic cars at the runtime, when race is already happening? Thank you!
yes, just changing car->ai_state
you might change their behavior any time, you can even make the cars race in reverse. As TNFS only can handle up to 8 cars, do when in a head to head race, the 6 remaining slots were for traffic/police.
The tnfs_ai_drivers_update()
is a quirky version from how TNFS handle it originally. It's also missing a lot of police car code, I should bring this part next time!
@marcos2250 thanks, I'm constantly updating your library in my project. Now all kinds of races work as expected apart from dumb AI and traffic not obeying lanes :)
I noticed one curious thing: by comparing car.position
changes each frame and linear velocity vector [car.speed_x
, car.speed_y
, car.speed_z
], the position delta is always slightly greater than linear velocity. I calculated it thoroughly and found that it almost exactly equal if FPS would've been 24, not 30. Do you have any idea how it is possible? I see your constants car.fps
and car.delta_time
, thy look correct and correspond to 30 frames per second
I recorded comparison test between dos TNFS and yours physics backend: https://www.youtube.com/watch?v=M_II5Gd8RGk
UPD: I figured it out, sorry for noise. Apparently all formulas were written for tick == 1/24 seconds, and for 30 fps developers just patched everything related to length: made track distance, display speed, speed in stats 0.8x.
Very intriguing why they did make this messed that way.
I found it odd that the delta_time const is also 0x888 (1/30) on 3DO, looks like they tried to make it real time 30 fps sim, but the hardware couldn't render 30 fps.
On PC/PSX versions, as in the lines 738,739 (linear) and 820 (rotation) of tnfs_fiziks.c, they added the fix2() macro call increasing vectors 25% without changing displayed speed!
Hello again @marcos2250
I don't see any license assigned to your project, so just wanted to ask: can I use your project as physics backend for my project The Need For Speed Web ? I'm going to implement wrapper which builds your code to WASM and creates bindings to the engine so it will work in browser. And for sure I will put a link to your repo there as well. Thanks!