Train Factory
Moderator: Moderators
Train Factory
Hello!
This is my first time posting on the SpringRTS dev forums, I usually post on ZK ones.
Like the title of my post implies, I'm trying to figure out how to build a train factory. I have most of the movement concept down (Not going to use rails, Just gonna put a lot of movement restrictions on that way it requires terraforming)
The thread I've posted all of my stuff in is here:
http://zero-k.info/Forum/Thread/20224
Also been using this guys ideas:
viewtopic.php?t=17137&start=20
The main thing i'm wondering about is how to attach the trains to one another. Is there a feature on unit behaviour that makes units do that?
This is my first time posting on the SpringRTS dev forums, I usually post on ZK ones.
Like the title of my post implies, I'm trying to figure out how to build a train factory. I have most of the movement concept down (Not going to use rails, Just gonna put a lot of movement restrictions on that way it requires terraforming)
The thread I've posted all of my stuff in is here:
http://zero-k.info/Forum/Thread/20224
Also been using this guys ideas:
viewtopic.php?t=17137&start=20
The main thing i'm wondering about is how to attach the trains to one another. Is there a feature on unit behaviour that makes units do that?
Re: Train Factory
It will probably be worth using dev engine so you can utilise new attachment / transport features:
viewtopic.php?f=12&t=33843
viewtopic.php?f=12&t=33843
Re: Train Factory
So maybe use attachunit?
Re: Train Factory
Certainly will be the best way of attaching them.
Also, sketchup is terrible for modelling for Spring IMO.
Also, sketchup is terrible for modelling for Spring IMO.
Re: Train Factory
Imo use the MoveCtrl functions to set positions of the waggons, like you would in a snake game. https://www.google.de/?gws_rd=ssl#q=gam ... rial+snake
Spring's attach/transport functions do not seem useful for trains.
Assuming you have the locomotive and each waggon as a seperate unit and attach them like this:
locomotive waggon1 waggon2 waggon3
Now the locomotive begins a turn and rotates. All the waggons insantly follow the motion and rotate on a arc with center on the locomotive. Train waggons should only begin to turn once they are on the bent part of track. In spring1944 you can test with the trucks and guns how units attached to each others behave.
The connection is rigid and so the towed gun-unit swings out behind the truck like a stick.
Looks acceptable for a short truck-trailer comb but unuseful for a longer train.
Assuming you have the tracks as units that "transport" the locomotive and waggons then that you have to deal with lots of annoying extra annoyances, and you will still need some logic to keep the waggons attached to each other.
Spring's attach/transport functions do not seem useful for trains.
Assuming you have the locomotive and each waggon as a seperate unit and attach them like this:
locomotive waggon1 waggon2 waggon3
Now the locomotive begins a turn and rotates. All the waggons insantly follow the motion and rotate on a arc with center on the locomotive. Train waggons should only begin to turn once they are on the bent part of track. In spring1944 you can test with the trucks and guns how units attached to each others behave.
The connection is rigid and so the towed gun-unit swings out behind the truck like a stick.
Looks acceptable for a short truck-trailer comb but unuseful for a longer train.
Assuming you have the tracks as units that "transport" the locomotive and waggons then that you have to deal with lots of annoying extra annoyances, and you will still need some logic to keep the waggons attached to each other.
- Attachments
-
- truck.gif (869.83 KiB) Viewed 6429 times
Re: Train Factory
I wonder why people use this simple to use tools, instead of all the fancy - stuff. Surely is the peoples fault, definitely not that my perspective is biased by years of exp. Never meet them halfway, by creating for example a shader that would decently texture a sketchup created unit. Filthy casuals.FLOZi wrote:Certainly will be the best way of attaching them.
Also, sketchup is terrible for modelling for Spring IMO.
Regarding the train. You can make the wagons, units of their own, following the motherunit, with motion ctrl only kicking in when the distance gets to big.
You could fake it, by having two models for turns, adjusting the wagons axis and height by finding the piecepositions height on the map and basically program a small physicsim in lua. This road is tempting and expensive and very complicated.
The Move restriction idea does not produce really pretty results... units moving along, snap around the corners in 90° .
Finally you can combine these. Have a unit, that is one unit as long as its standing still, and turns into several once going.
Have fun..tschoo.. tschoooo
Re: Train Factory
I disagree. S44 truck & gun is a single unit, not attached. Anyway with atachments you can rotate the attachment piece to turn each part... it is the way to go. Using movectrl every frame is less reliable in my experience.8611z wrote:Imo use the MoveCtrl functions to set positions of the waggons, like you would in a snake game. https://www.google.de/?gws_rd=ssl#q=gam ... rial+snake
Spring's attach/transport functions do not seem useful for trains.
Re: Train Factory
MoveCtrl is complex, so many bad and weird things can happen from conflicts and happy collisions with other parts of the code.
Having a unit attached to a unit attached to a unit... where every attach point is a free invisible piece may be a nice way to implement a train with some silly script updating the attach point piece in absolute rather than model coordinates to rotate/follow the transporter.
Having a unit attached to a unit attached to a unit... where every attach point is a free invisible piece may be a nice way to implement a train with some silly script updating the attach point piece in absolute rather than model coordinates to rotate/follow the transporter.
Re: Train Factory
Some of the guns in S1944 do work via the transport-methode. Whether the gif shows a single unit that deploys via "morph" gadget or or two "loaded" units does not really matter: The effect looks excactly the same and so shows the problem just as well.
I am not sure sure if moving & rotating the attach-pieces helps:
No matter how you rotate the attach-points between waggons, the train as whole will always travel in the same direction.
In a real train waggons can travel in different directions.
The rotation works different, the movement works different, it would be so much "adjusting" the attach-pieces that one might as well not attachUnit anything.
Basically it would be two steps:
1) Undoing all the movement of the previous waggon
2) Doing the movement you actually want
With moveCtrl first step is not nessecary.
moveCtrl stuff works very nice. It has been used for jumpjets, making non-fly-stuff fly, conveyor belts, underground digging units, ...
I am not sure sure if moving & rotating the attach-pieces helps:
No matter how you rotate the attach-points between waggons, the train as whole will always travel in the same direction.
In a real train waggons can travel in different directions.
The rotation works different, the movement works different, it would be so much "adjusting" the attach-pieces that one might as well not attachUnit anything.
Basically it would be two steps:
1) Undoing all the movement of the previous waggon
2) Doing the movement you actually want
With moveCtrl first step is not nessecary.
At that point there is not much difference left to using SetUnitPosition()some silly script updating the attach point piece in absolute rather than model coordinates
moveCtrl stuff works very nice. It has been used for jumpjets, making non-fly-stuff fly, conveyor belts, underground digging units, ...
Re: Train Factory
Ive spend half a year on/off lua-porting the nehe-rope physics. Rope == train.
And its funny.
Inefficient.
Not working at all.
But funny.
And its funny.
Inefficient.
Not working at all.
But funny.
Re: Train Factory
My idea exactly. I wanted to place a node on the train model. Would that work with attachments?Having a unit attached to a unit attached to a unit... where every attach point is a free invisible piece may be a nice way to implement a train with some silly script updating the attach point piece in absolute rather than model coordinates to rotate/follow the transporter.
Re: Train Factory
Perhaps but those s44 units make no attempt to address the problem.8611z wrote:Some of the guns in S1944 do work via the transport-methode. Whether the gif shows a single unit that deploys via "morph" gadget or or two "loaded" units does not really matter: The effect looks excactly the same and so shows the problem just as well.
You may be right. I guess it depends on a. the length of the train and b. most critically, if curved tracks are required and how gently they curve.I am not sure sure if moving & rotating the attach-pieces helps:
No matter how you rotate the attach-points between waggons, the train as whole will always travel in the same direction.
In a real train waggons can travel in different directions.
The rotation works different, the movement works different, it would be so much "adjusting" the attach-pieces that one might as well not attachUnit anything.
Basically it would be two steps:
1) Undoing all the movement of the previous waggon
2) Doing the movement you actually want
With moveCtrl first step is not nessecary.At that point there is not much difference left to using SetUnitPosition()some silly script updating the attach point piece in absolute rather than model coordinates
moveCtrl stuff works very nice. It has been used for jumpjets, making non-fly-stuff fly, conveyor belts, underground digging units, ...
Re: Train Factory
This should really not break anyone's mental budget...
1) define your track as a list of connected (pos, dir, length) segments
2) define your train as a list of units ([0]=head, [1]=first wagon, etc) all moving at the same speed
3) for all units in train: find track segment based on position, set direction to match, move along track
4) goto 3
Like knorke said, composite transporters or rope physics nonsense are *not* needed, basic MoveCtrl will do.
If you want to be fancy, use splines for curved segments, or allow each wagon to have a front and rear bogie (appropriately offset along the z-axis) and interpolate direction whenever the front bogie is on a different part of track than the rear. If not, just snap it for TTD-style trains.
1) define your track as a list of connected (pos, dir, length) segments
2) define your train as a list of units ([0]=head, [1]=first wagon, etc) all moving at the same speed
3) for all units in train: find track segment based on position, set direction to match, move along track
4) goto 3
Like knorke said, composite transporters or rope physics nonsense are *not* needed, basic MoveCtrl will do.
If you want to be fancy, use splines for curved segments, or allow each wagon to have a front and rear bogie (appropriately offset along the z-axis) and interpolate direction whenever the front bogie is on a different part of track than the rear. If not, just snap it for TTD-style trains.
Last edited by Kloot on 01 Feb 2016, 11:57, edited 2 times in total.
Re: Train Factory
The question is about trains not on tracks, of course if you have tracks situation is considerably simpler.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Train Factory
I have no idea what a "train without tracks" is supposed to do.
Re: Train Factory
I figured it's like a bunch of kids doing a human train
Re: Train Factory
That seems even more basic, ever played Snake?trains not on tracks
Whatever movement carriage i executes, carriage i+1 repeats (length/speed) frames later for all i.
edit@below: nah, knorke beat both of us ("use the MoveCtrl functions to set positions of the waggons, like you would in a snake game")
Last edited by Kloot on 01 Feb 2016, 12:51, edited 1 time in total.
Re: Train Factory
EDIT: Kloot beat me to it
Re: Train Factory
Trains in spring would be awsome, i loved them in tibsun, if they had gameplay mechanics that would be so rad.
Re: Train Factory
The problem with tracks is that to use them, they have to be built as units. Apparently I can't use typemap (Area 17 fires anyone?) for tracks.