Train Factory

Train Factory

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Parzival
Jauria RTS Developer
Posts: 14
Joined: 30 Jan 2016, 19:08

Train Factory

Post by Parzival »

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?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Train Factory

Post by FLOZi »

It will probably be worth using dev engine so you can utilise new attachment / transport features:

viewtopic.php?f=12&t=33843
Parzival
Jauria RTS Developer
Posts: 14
Joined: 30 Jan 2016, 19:08

Re: Train Factory

Post by Parzival »

So maybe use attachunit?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Train Factory

Post by FLOZi »

Certainly will be the best way of attaching them.

Also, sketchup is terrible for modelling for Spring IMO.
8611z
Posts: 169
Joined: 08 Jul 2015, 20:20

Re: Train Factory

Post by 8611z »

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 :arrow: waggon1 :arrow: waggon2 :arrow: 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.
Image
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
truck.gif (869.83 KiB) Viewed 6429 times
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Train Factory

Post by PicassoCT »

FLOZi wrote:Certainly will be the best way of attaching them.

Also, sketchup is terrible for modelling for Spring IMO.
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.


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
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Train Factory

Post by FLOZi »

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.
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.
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: Train Factory

Post by hokomoko »

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.
8611z
Posts: 169
Joined: 08 Jul 2015, 20:20

Re: Train Factory

Post by 8611z »

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.
some silly script updating the attach point piece in absolute rather than model coordinates
At that point there is not much difference left to using SetUnitPosition()

moveCtrl stuff works very nice. It has been used for jumpjets, making non-fly-stuff fly, conveyor belts, underground digging units, ...
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Train Factory

Post by PicassoCT »

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.
Parzival
Jauria RTS Developer
Posts: 14
Joined: 30 Jan 2016, 19:08

Re: Train Factory

Post by Parzival »

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.
My idea exactly. I wanted to place a node on the train model. Would that work with attachments?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Train Factory

Post by FLOZi »

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.
Perhaps but those s44 units make no attempt to address the problem.
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.
some silly script updating the attach point piece in absolute rather than model coordinates
At that point there is not much difference left to using SetUnitPosition()

moveCtrl stuff works very nice. It has been used for jumpjets, making non-fly-stuff fly, conveyor belts, underground digging units, ...
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.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Train Factory

Post by Kloot »

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.
Last edited by Kloot on 01 Feb 2016, 11:57, edited 2 times in total.
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: Train Factory

Post by hokomoko »

The question is about trains not on tracks, of course if you have tracks situation is considerably simpler.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Train Factory

Post by Silentwings »

I have no idea what a "train without tracks" is supposed to do.
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: Train Factory

Post by hokomoko »

I figured it's like a bunch of kids doing a human train
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Train Factory

Post by Kloot »

trains not on tracks
That seems even more basic, ever played Snake?

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.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Train Factory

Post by gajop »

Image
EDIT: Kloot beat me to it :(
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Re: Train Factory

Post by code_man »

Trains in spring would be awsome, i loved them in tibsun, if they had gameplay mechanics that would be so rad.
Parzival
Jauria RTS Developer
Posts: 14
Joined: 30 Jan 2016, 19:08

Re: Train Factory

Post by Parzival »

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. :(
Post Reply

Return to “Game Development”