Transport Fever

Transport Fever

Not enough ratings
[ MODDING ] Adding passengers
By OlaHaldor
A look into how you can make passengers spawn in your vehicle.
   
Award
Favorite
Favorited
Unfavorite
First steps
Before you start adding passenger spawn locations you need to add this to the top of the .mdl file of your vehicle.

local vec3 = require "vec3" local transf = require "transf"

Then you need to make the seats section.

Find the transportVehicle section in the .mdl, and add the following within the section:
seats = { }

For my Flirt mod, it looks like this:
transportVehicle = { capacities = { { capacity = 180, type = "PASSENGERS", }, }, carrier = "RAIL", loadSpeed = 4, multipleUnitOnly = true, seats = { } },
Finding the Seat Coordinates
An easy way to find out where your passengers should spawn, is to open the 3D model of your mod in your 3D application of choice.

Depending on your 3D app, this may be named different. In some it's a null, in others it's a locator.

In my case I use Modo, and I'm going to make a locator.

Finding the coordinates
I hide all the bits of the model I don't need to see, and make a locator.
I move the locator to the height of the floor, and place the locator centered on the seat.



Then I take note of the position for the locator.
Adding the coordinates to the .mdl file
Now you're ready to populate the seats!

In the seats section, add the following bit of code:
{ group =1, transf = transf.rotZYXTransl(transf.degToRad(0.0, 0.0, 0.0), vec3.new(0, 0.0, 0.0))},

The coordinates are written in this order: Z, X, Y. Not the usual X, Y, Z we know from 3D modeling. It can be a bit confusing in the beginning, but once you get into the habit of copy/pasting values like this you'll be fine.

NOTE: This may not be true for all vehicles, so take some time and test thoroghly.
What I've found is the placement of these locators are mirrored. Positive values on the X axis are inverted. This means: where there is a minus sign in front of the value in the 3D app, it have to be positive in the .mdl file.


Here's an example:
The Y is the floor level, Z and X are the center of the seat.
I placed a locator in my 3D model at these coordinates.

X: 1.1 Y: 1.27 Z: -3.7081

In the .mdl file this will be written as
3.7081, -1.1, 1.27
Notice the Y value is unaltered while the X value have become positive instead of negative.

With all this in mind, here's a couple of examples. Notice the first number orients the seat at 90 and 180 degrees rotation.

seats = { { group =1, transf = transf.rotZYXTransl(transf.degToRad(0.0, 0.0, 0.0), vec3.new(2.7319, -1.1, 1.27))}, { group =1, transf = transf.rotZYXTransl(transf.degToRad(180.0, 0.0, 0.0), vec3.new(3.7081, -1.1, 1.27))}, { group =1, transf = transf.rotZYXTransl(transf.degToRad(-90.0, 0.0, 0.0), vec3.new(-5.86, 1.1, 0.7099229))}, }
Standing Passengers and Crew
There are two tags you can use on a seat. They are crew and standing.

The crew tag is handy to use while placing the seats and checking whether the position and orientation of the seat is correct. The tag will spawn a crew member of your vehicle from the get go, and you don't need to have a functional line between two towns and populate the train with passengers before checking how the seats are placed. It will save you a lot of time!

The standing tag will determine whether the passenger (or crew) is sitting or standing.

Example:
{ group =1, transf = transf.rotZYXTransl(transf.degToRad(-90.0, 0.0, 0.0), vec3.new(0.5646496, -0.1225953, 0.7099229)), standing = true}, { group =1, transf = transf.rotZYXTransl(transf.degToRad(-90.0, 0.0, 0.0), vec3.new(0.5646496, -0.1225953, 0.7099229)), crew = true}, { group =1, transf = transf.rotZYXTransl(transf.degToRad(-90.0, 0.0, 0.0), vec3.new(0.5646496, -0.1225953, 0.7099229)), crew = true, standing = true},

4 Comments
Fimilfinfaon 12 Jul, 2019 @ 12:57pm 
What does the group = 1 do?

It corresponds (group X =) to the object which will be attached to the passengers (always put the corresponding object where the passengers are seated, in general it is the main body) do not especially put objects (group) in movement.
OlaHaldor  [author] 19 Jul, 2018 @ 1:24am 
BGR
I actually have no idea :)
BGR 18 Jul, 2018 @ 11:22pm 
What does the group = 1 do?
Lagislazuli 14 Nov, 2016 @ 1:25am 
Thanks for the guide, it helped me a lot.
Just a sidenote to the coordinates. Actually it is ordered X, Y, Z but based on the (central?) european coordinates. We use X, Y for the flat or ground view and Z is the height (floor level).