- Task
- Vehicle Physics Pro
- GLTFUtility
- Csharp’s interpretation of Json
- Abstract the vehicle as a Json structure
Task
- Load car configuration from .json file
- Compose DevDocs
- Investigate csharp comment documentation
- use assimp to load .glb model
Vehicle Physics Pro
Starting point
The unity’s build-in physics engine PhysX is far from being precise enough for a vehicle simulator.
Needs
- Closer to reality vehicle physics
- Runtime performance
- Not so complicated to config so that the composition of the savings and editor will not be a headache
Install
Through Asset Store
GLTFUtility
Starting point
The car model should be customizable, i.e. the user drag a car model into a directory and the game should be able to load it.
Filetype .glb is nice but unity doesn’t have build-in support
Needs
- Runtime import
- support mesh and material
Install
In tactics project:
1 | git submodule add https://github.com/Siccity/GLTFUtility.git ./Tactics/Assets/ThirdParty/GLTFUtility |
Runtime API
1 | using Siccity.GLTFUtility |
here I use Application.streamingAssetsPath+"/Model/"+JsonReader.vehicle.model.carBody[0].dir
as filepath
Trouble shooting
- In the built game, encounter
ArgumentNullException: Value cannot be null. Parameter name: shader
Github Issue - The file management of the game changed after being built. How to determine where to place the
Save
andModel
folders?
UseApplication.streamingAssetsPath
, stands forAssets/StreamingAssets
in Unity editor andGame_Data/StreamingAssets
in exported game.
Csharp’s interpretation of Json
First construct the structure of the json file in c#.
Notice: the name of the member variable should be the same with those in json file
1 | [System.Serializable] |
Notice: [System.Serializable]
is for serialized display in Unity editor.
Then, directly use build-in json loader:
1 | VehiclePara vehicle; |
All the parameters will be stored in the instance vehicle
.
Abstract the vehicle as a Json structure
Graph
1 | flowchart RL |
Json example
1 | { |