Script extracts from https://gdn.giants-software.com/documen ... g_fs22.php
AI controlled for pickup/delivery/drive to/from on a map by the following
!. AI spline
2. Terrain Texture
3. Road/traffic spline
4. Navigation collision mask
AI Spline
Is simply a normal spline created the same as for a traffic spline contained in a AI_Spline transform group with the onCreateAttribute --AISystem.onCreateAIRoadSpline assigned to it and doesn't have a maxSpeed or speedLimit applied to the individual splines, which along with the maximum width of the AI is set in the relevant LUA script.
The AI also a limited detection range to splines/textures which can be as low as 10m in some cases, it also has other restriction on size etc as this extract from the AISystem.lua shows
Code: Select all
self.cellSizeMeters = 1
self.maxSlopeAngle = math.rad(15)
self.infoLayerName = "navigationCollision"
self.infoLayerChannel = 0
self.aiDrivableCollisionMask = CollisionFlag.AI_DRIVABLE
self.obstacleCollisionMask = CollisionFlag.STATIC_OBJECTS + CollisionFlag.AI_BLOCKING + CollisionFlag.STATIC_OBJECT
self.vehicleMaxHeight = 4
self.defaultVehicleMaxWidth = 6
self.defaultVehicleMaxTurningRadius = 20
self.isLeftHandTraffic = false
There is a specific attribute in the <Layer> entry for use by the AI to determine the easiest path to take, example below
<Layer name="animalMud04" detailMapId="14" normalMapId="15" unitSize="2" unitOffsetU="0" unitOffsetV="0" weightMapId="13" blendContrast="0.2" attributes="0.043 0.029 0.02 1 1 8"/>
<Layer name="concrete01" detailMapId="17" normalMapId="18" unitSize="2" unitOffsetU="0" unitOffsetV="0" weightMapId="16" blendContrast="0.2" attributes="0.394 0.362 0.301 0 7 2"/>
The last figure in the attributes section at the end of the <Layer line is the one used by the AI
-- animalMud04 '8" harder path for ai
--concrete01 '2' easier path for AI
So if a modder wished he could, for example create a duplicate ingame single grass texture with a final attribute of '1' so the AI choses that path over any other (grass in the US map is '8') a width of about 2-4m should suffice anything larger might cause the AI to wander.
Painting a low value texture such as Asphalt under the road mesh can also give a performance advantage by allowing a lower clip distance on the road mesh without any visual loss when viewed from a distance.
Roads and Traffic Splines.
The road mesh itself has specific collisionMask for AI of (hex) 400df, this consists of the following
Code: Select all
0: "DEFAULT: The default bit",
1: "STATIC_WORLD: Collision with terrain, terrainHeight and static objects",
2: "STATIC_WORLD_WITHOUT_DELTA: Deprecated in FS22: Do not use it anymore!",
3: "STATIC_OBJECTS: Collision with static objects",
4: "STATIC_OBJECT: A static object",
Deselected is 5: "AI_BLOCKING: Blocks the AI",
6: "TRACTOR: Deprecated in FS22: Do not use it anymore!",
7: "COMBINE: Deprecated in FS22: Do not use it anymore!",
18: "AI_DRIVABLE: AI can drive over this node",
So any Road/lane /track mesh should have this value set
Traffic Splines
The AI will obviously use traffic splines where it can so the AI spline is just laid laid alongside the traffic spline at the relevant place (see Elmcreek map AI spline 'underBridgeA' and Trafic spline 'overBridgeA_blocked' for example)
Navigation collision mask
You can also stop the AI from going in certain directions by using the navigationCollision mask in GE
Info Layer Painting--Info Layer --select navigationCollision in dropbox,
Map will turn white red areas painted are no go area's.
To paint -select the info Channels 0 - map will change to show no go area's in white - then just paint the areas you want the AI to avoid in white - when done deselect the info Channel 0 (map turns white and areas go from white to red) and save the map.
The image below shows the spline layout for the default Elmcreek Map
AI in Green, traffic in Red you willsee that there is hardly any AI specific splines compared with the Traffic splines as the map uses the terrain textures for navigation,
One interesting section is the area where the river forks where an AI spline diverts the AI through a ford if the AI vehicle exceeds the maximum width/height settings.
Problem with semi trucks on corners.
In real life these vehicles swing wide on corners so why not add an AI spline that does the same thing, the AI should follow a AI spline over a traffic spline , and it would only need to be a short spline just covering the corner itself.