How does the train.m object works exactly?
If I place a customized train object (Replaced models: train.m, train2.m, train3.m; Replaced NCP: train.ncp; Replaced sounds: train.wav, whistle.wav) on my map on location (a1), it moves in one direction, until it reach point (z1). It respawns on point (y1) and move to point (z1) again. From this time, it always move from (y1) to (z1).
I wasn't able to find out, why the object stop moving at point (z1), and I also was not able to find out why it respawns at point (y1).
If I place a second train object at location (a2), it moves to (z2), it respawns at (y2), move to (z2) again, and so on.
The strange thing is: (a1) and (a2) are on different axis. (y1) and (y2) are on the same axis, as well (z1) and (z2).
If I place train objects at (a3), (a4), (a5), (a6), and so on, it always react the exactly same way as described above: Stop at z, respawn at y.
Maybe the y and z axis are hardcoded?
Here a picture for better understanding:
train.m Object
Re: train.m Object
Assuming it's the same as the leaked source that's been floating around, it looks to me like it's handled by this:
...which leads me to think that it's only looking at the z axis. So in the diagram (y) would be z=-400, and (z) would be z=-11500.
If (a) is 'left of' -400 then it'll move 'to the right' towards it just fine, but when it respawns it just goes directly back to -400 rather than the location of the placed object.
Indeed just a bit of old hardcoding, unfortunately.
Code: Select all
// move train
CopyVec(&obj->body.Centre.Pos, &obj->body.Centre.OldPos);
obj->body.Centre.Pos.v[Z] -= TimeStep * 200.0f;
if (obj->body.Centre.Pos.v[Z] < -11500)
obj->body.Centre.Pos.v[Z] = -400;
If (a) is 'left of' -400 then it'll move 'to the right' towards it just fine, but when it respawns it just goes directly back to -400 rather than the location of the placed object.
Indeed just a bit of old hardcoding, unfortunately.
Re: train.m Object
Thanks for this source code snippet and the describtion. Yes, this make sense.
As a change of this behaviour (replacing "-400" with the initial position of the object) would have bad influence to train objects placed on old tracks, this couldn't be changed in future RVGL releases, I guess.
As a change of this behaviour (replacing "-400" with the initial position of the object) would have bad influence to train objects placed on old tracks, this couldn't be changed in future RVGL releases, I guess.
- hajducsekb
- Posts: 78
- From: ~/
Re: train.m Object
Couldn't it default to -400 for any track/train object not containing this parameter, and still have it as an option in makeitgood to customize it?
HAJDUC DOT COM