Jump to content

Simple Railway mod in development. Kerbtown based.


Tw1

Recommended Posts

I am working on a simple railway mod. The plan is to have track pieces that you put together, like a model railway, placed using the kerbtown plugin. Train wheels grip a central, T shaped bar.

Currently, I have a working bogie part, which still needs refinement before I move on to track making.

Your ideas, or offers to help are most welcome.

The original idea (discussed in the first few pages) was a system inspired by the kerbals' ladders.

Kerbals lock on to the ladders, move straight from one to another, even at a slight angle. A similar system could be employed to make a train wheels jump from one rail segment to another. These segments will be placed via kerbtown, with the possibility of adding a resource-using construction system later.

A radially place able train bogie (wheel frame) part will enable your creations to use the track.

This "ladder" based concept was superseded by the current idea, which is based on monorail.

The other issue with creating a rail system is terrain. Real life railway engineers can modify terrain to make a better path, but obviously we can't in KSP. A solution could be to make every segment a viaduct.

Model for demonstration only.

The supports here are 500m tall, so they should be enough to cross reasonable changes in terrain. When not needed, they will be hidden underground, giving the impression of a smaller structure.

Current planed parts:

G8p0hj1.jpg

(I forgot to include a label for the incline piece)

(Specifics of each are still under discussion.)

The early version of the bogie. T-shape proved more reliable than V shape in testing.

A coupler part to let you join train parts together, featuring a hinge, and a docking port like end for convenient assembling of trains will also be included eventually.

Track dimensions:

2mFyLPz.png

Note that this has been tweaked a little from the last post.

First post will be edited now and then, to show any big news, or changes in the plan.

Edited by Tw1
Moving from discussion to development
Link to comment
Share on other sites

First off:

http://wiki.kerbalspaceprogram.com/wiki/Adding_Airlocks_and_Ladders_to_Parts

That should answer any questions you have about ladders and how to make em.

There is one MAJOR hole in doing rails like your thinking. If you make it out of parts then its the same a loading a ship of the same number of parts. Bottom line, even with HUGE rails sections, your talking about adding massive resource usage for even a tiny rail system.

I think the best way to go about this (or anything else that would be this large scale) is gonna be using static object to create most of the infrastructure.

KerbTown already allows the placement of static objects:

http://forum.kerbalspaceprogram.com/showthread.php/40374-WIP-KerbTown-v0-12-1-Beta-Place-static-buildings-cities-launch-sites-more!

With some additional code im sure a rail system would be very feesable. Making the rails all static objects, with a small vessel for railcar would GREATLY reduce the overall impact of such a system.

That being said I can not code, not even a little, so thats as far as I can go with the idea....

Link to comment
Share on other sites

Some time back we tried monorails:

8675242660_ef28049f2b_c.jpg

( there was another one using I-beams ). However there were two major snags almost immediately:

* Part count - even keeping it as minimalist as possible it didn't take many segments to hit horrible part limits

* You've got to lay the thing somehow.

Technically there's no difference between a rover autonomously going along a path and a rail vehicle - it doesn't actually have to be guided by real physical rails as such, although if you can get the infrastructure down there's no reason not to either. Mostly though, work out how you're going to lay a path asset ( it's the same for roads ) and have it conglomerate itself to the point it's not going to instantly murder FPS. The path is fixed so it doesn't need physics performed on it, which should help.

Link to comment
Share on other sites

Well, I think the optimal solution to this would be a "melding" of what's been said. You lay the rail as parts (launched as a pack or something, maybe, so you can build railways on other bodies - Evian inter-colony high-speed rail system, anyone?), and then it becomes part of the scenery, like the space center buildings. Basically, you launch a construction kit, that lets you lay a certain length/type of track, and then the game treats it as an immutable object once it's laid. Nicely takes care of the structural strength issue, too (you can't knock over the VAB, after all).

Dunno how workable that is, though. You'd obviously have to write some sort of plugin (a fork of KerbTown? I dunno).

Link to comment
Share on other sites

Good idea, I'm assuming the main use would be to replace rovers?

Not so much rovers, but replacing suborbital vehicles for resource collection and transporting kerbals over reasonable distances. I imagine using something like this with Kethane, and the like. With a special path that holds the vehicle in place, you could accelerate to speeds much higher than what rovers do.

There is one MAJOR hole in doing rails like your thinking. If you make it out of parts then its the same a loading a ship of the same number of parts. Bottom line, even with HUGE rails sections, your talking about adding massive resource usage for even a tiny rail system.

The idea would be each 2.5 K.m section would be a single part that you must deliver to the right location, aim, then anchor down. The line itself is the (physics-free?) extendible ladder. This would result in only a few parts per Km2.

Kerbtown was my first thought when it came to this, but I wasn't sure about how things were placed in it. Having a closer look, seems it has a GUI that lets you place things.

That seems bit easy though, a lot goes into making a railway.

If they were parts, construction could be done with EL, where you have to mine the ore to make the part, and then get it somewhere. This would make building a rail line a fair task, for the benefits it brings.

Though if they were done as parts, you'd have a lot of vessels in the map view list just making up the railway.

Edit:

Well, I think the optimal solution to this would be a "melding" of what's been said.

That's an interesting thought. I wonder if something could be made to work like kerbtown, but spawn from a part. The part could be one use only, then be deleted, leaving the map clear.

Edited by Tw1
Link to comment
Share on other sites

I wonder if something could be made to work like kerbtown, but spawn from a part. The part could be one use only, then be deleted, leaving the map clear.

Well, that was my thought in a nutshell. I dunno too much about the internals of KerbTown, though (haven't played with it), and specifically whether you can only place stuff OUTSIDE the game. If that's the case, something new would be needed.

After some thought, you'd probably have to work out the track-laying mechanic in a "Railroad Tycoon" sort of way, to prevent your train from jumping the tracks between sections. Basically, there would be some interesting spline modelling going on to create smooth track curves and the like. I'm pretty sure, however this works out, there would be a very heavy programmatic/mathematical element to any plugin this approach would produce.

Edited by NGTOne
Link to comment
Share on other sites

You also have to consider things like physics and view distance.

If the rail is made of part it will have to follow some physics rules as any other ship.

Also, your talking about a 2.5km part...thats greater than the stock ksp load distance for vessles. I have seen what happens when a single craft breaks the 2km load distance with KAS...its not purdy at all lol...lots of exploding.

Using statics would help on both counts. Static objects don't follow the same physics rules as parts do. If the rail is parts whats happens when a rocket launch goes pearshaped....BOOM there goes 5km of your rails system ya spent days to make! Wouldn't happen with static object..like VAB.

As for making it challenging you could code that behavior in as well. make it so Kerbals have to be within 2m of rail orgin to place a section. Or implement a cash/resource system to buy rail sections.

Either way, if this is gonn abe done large scale and made playable, if its parts or static its gonna need a plugin. With that in mind why not go for whats best for system usage.

Link to comment
Share on other sites

As for making it challenging you could code that behavior in as well. make it so Kerbals have to be within 2m of rail orgin to place a section. Or implement a cash/resource system to buy rail sections.

Well, the challenge could be in the weight as well. Train tracks aren't exactly light, and there could be several different types (classical/high-speed/maglev), with differing masses, costs, and performance characteristics. Imagine having to launch a 100-ton kit from the KSC to lay 1km of track, and you get the general picture. Might make for some interesting designs in terms of track-laying infrastructure - imagine, for instance, a train that takes track kits from spaceships at a landing zone, transports them to the railhead, and installs them.

Link to comment
Share on other sites

I haven't checked Kerbtown yet, but it's probably a good idea to stop thinking of track ( and roads ) in terms of parts - parts have physics applied, and these do not, and they also need to at least attempt to meld with the terrain rather than just sit on top ( unless you're making a suspended monorail or something ). I would suggest what you actually want to do is go and survey a route via rover/aircraft/satellite/walking/random guessing on the planet map, marking down important points in the route and then have something generate a spline, and have it work out how many segments it wants to cut the path in to. Ideally you'd want an editable bezier spline, but I fear that'd take a bit of work to make an editor for...

After that you can worry about resource costs before whatever mechanism you use generates the infrastructure. Hopefully the mechanism can make sure there's no gap between the road bed and the ground, and so on.

Link to comment
Share on other sites

I haven't checked Kerbtown yet, but it's probably a good idea to stop thinking of track ( and roads ) in terms of parts - parts have physics applied, and these do not, and they also need to at least attempt to meld with the terrain rather than just sit on top ( unless you're making a suspended monorail or something ). I would suggest what you actually want to do is go and survey a route via rover/aircraft/satellite/walking/random guessing on the planet map, marking down important points in the route and then have something generate a spline, and have it work out how many segments it wants to cut the path in to. Ideally you'd want an editable bezier spline, but I fear that'd take a bit of work to make an editor for...

After that you can worry about resource costs before whatever mechanism you use generates the infrastructure. Hopefully the mechanism can make sure there's no gap between the road bed and the ground, and so on.

I think elevated tracks are kind of a given for this sort of system, no matter what model of track design you're using. The land in KSP doesn't curve smoothly enough to permit proper train operation (you hit an angle in the terrain and your train goes flying - anyone who's tried to drive a long, rigid rover with low clearance - which is basically what a train is, but linked together in series - knows what I mean), and it would allow for shallower grades and bridges and whatnot at any rate. You'd end up needing to model the track in 3D space, but that's been done before (any model railway design/build simulator comes to mind). If you wanted the track to hug the terrain, you just change the elevation to 0 and the "elevated" part is beneath the ground.

In my opinion, this mod needs to happen. It sounds AWESOME.

Edited by NGTOne
Link to comment
Share on other sites

I think elevated tracks are kind of a given for this sort of system, no matter what model of track design you're using.

In my opinion, this mod needs to happen. It sounds AWESOME.

Yeah, Elevated tracks would be it. May post a sketch of the sort of thing I'm thinking.

For a long time last year, I mucked around with the Editor mode in Kuju rail sim. Viaducts of certain heights could be made by lowering hight you didn't want through the ground, but it meant if you raised them too high, they'd be floating in mid air.

But something like that could do for this.

They had a very cool system for joining tracks into junctions, making curves, creating multi track lines. But if I was to work on something like this, I could never achieve that. (got to eat, sleep, and do uni work some time.)

Making it work like the ladders could be advantageous, you just need to cross the ends of two track segments right, and the vehicle would cross over from one to another. It wouldn't look so smooth, but it would work.

I found this in the Kerbtown thread.

with a certain set of interfaces it would become very simple for any mod to tell KerbTown "Put this here", and provide their own independent mechanics on how the player is allowed to place statics within the world; and even their own GUI if they want.

So it could work. Based on what you guys have said, a static model placed from a part sounds like the way to go. But I couldn't make interfaces or plugins myself.

Link to comment
Share on other sites

Well, I'm thinking of roads - you may think "why", but it's smoother than the terrain, and other guided infrastructure - maglev, monorail, hovercraft, guided ballistic capsules, whatever you can think up - which might be happier with a less smooth path too. Laying it on the ground is a little cheaper graphically as you only have to worry about one side - whether that's worth it in KSP I don't know. It'd be worth finding out if you can patch the terrain, then whatever guideway model is needed can be a really simple thing.

Link to comment
Share on other sites

Well, I'm thinking of roads - you may think "why", but it's smoother than the terrain, and other guided infrastructure - maglev, monorail, hovercraft, guided ballistic capsules, whatever you can think up - which might be happier with a less smooth path too. Laying it on the ground is a little cheaper graphically as you only have to worry about one side - whether that's worth it in KSP I don't know. It'd be worth finding out if you can patch the terrain, then whatever guideway model is needed can be a really simple thing.

From what I understand of KSP, graphical cheapness doesn't actually count for much past a certain minimum threshold. The lag comes from the physics calcs, which use CPU rather than GPU time. I don't think you'd notice much difference between elevated tracks/roadways and ground-based, flat-surface ones in terms of graphical performance.

Link to comment
Share on other sites

i thought about doing something like this for offworld linear accelerators, where track lengths would be less than 1km. ladders work having a box collider. while on the ladder the kerbal will climb up the y axis of the collider. to do a linear accelerator you would do something similar. the kerbal would be replaced with a sled type part that could be connected to a ship. you position your ship in the accelerator and when the sled lines up with the track (detected by colliding with the box collider), you can then couple with the track which would cause the sled to levitate. then you could start the accelerator. track would come in straight sections about 20-50m and would dock up with integrated docking ports, and there would also be optional bits like modular pylons (to set the grade of the track), a loading platform, capacitor banks, and things like that.

from a physics standpoint you would only collide the sled with the box collider when loading the sled on the track, or during acceleration when it is no longer engaged with the current piece of track (to either re-engage the next piece, or enter flight). you also need to check that the sled collider is intersecting the box collider for the current track segment every frame, but this is a check between 2 known objects, and not an n^2 kinda thing to try to find out what you are attached to.

its a nice idea, but i dont want to delve into code at this time.

Link to comment
Share on other sites

. the kerbal would be replaced with a sled type part that could be connected to a ship. you position your ship in the accelerator and when the sled lines up with the track (detected by colliding with the box collider), you can then couple with the track which would cause the sled to levitate. .

By levitate, is that like the way kerbals grab the ladder? That way, you could just drive your vehicle to the track, trigger your conect to track action group and then you're away. Then, if the track is close enough to the ground, you could connect or disconnect easily.

I have drawn up the concept so far.

iNVywuG.jpg

Not the clearest photo, but you can see what I mean.

Segments would need to be a few lengths, from Km long ones, to 100m and maybe 10m.

Link to comment
Share on other sites

By levitate, is that like the way kerbals grab the ladder? That way, you could just drive your vehicle to the track, trigger your conect to track action group and then you're away. Then, if the track is close enough to the ground, you could connect or disconnect easily.

I have drawn up the concept so far.

-IMGSNIP-

Not the clearest photo, but you can see what I mean.

Segments would need to be a few lengths, from Km long ones, to 100m and maybe 10m.

Overlapping corners for curves might be problematic at high speeds - I kind of envisioned having several different kinds of track, from conventional to high-speed, with varying properties and train types. Even if that's not the case, your train might jump the tracks when it otherwise shouldn't, because it tried to physics-clip through a gap in the corner. Might be worth it to consider a spline-editor approach to tracklaying.

Link to comment
Share on other sites

Overlapping corners for curves might be problematic at high speeds - I kind of envisioned having several different kinds of track, from conventional to high-speed, with varying properties and train types. Even if that's not the case, your train might jump the tracks when it otherwise shouldn't, because it tried to physics-clip through a gap in the corner. Might be worth it to consider a spline-editor approach to tracklaying.

A curve part might be useful, ones that let you do different angles. Then, every part would go straight on to the next. But this depends on how ladder physics work, if someone could advise on this, that would be helpful.

I think differing types of track would have to wait until the mod actually existed, and may complicate things a little. I don't envision including rolling stock with this, but there's no reason someone couldn't make train models that would go on the bogies.

Spine editor would be the best, but unless someone who can code is interested, it will be limited to Kerbtown placeable parts.

Link to comment
Share on other sites

By levitate, is that like the way kerbals grab the ladder? That way, you could just drive your vehicle to the track, trigger your conect to track action group and then you're away. Then, if the track is close enough to the ground, you could connect or disconnect easily.

I have drawn up the concept so far.

-snip-

Not the clearest photo, but you can see what I mean.

Segments would need to be a few lengths, from Km long ones, to 100m and maybe 10m.

what i mean by levitate is that the sled (or train car for your example) is aligned to the z axis of the collider representing the track, its orientation is snapped to the collider's orientation (probibly with an eye pleasing animation), so the origin of the car passes through the origin of the box collider. the box collider would stretch from one end of the track part to the other. i believe i used the term "engage" the track. while an object is engaged to track it is constrained so that it may only translate along the z axis of the collider. if your car's collider exits the rail collider then you become disengaged, and before any physics would be applied it would search for another piece of track to engage.

i really only thought it out as far as munar launch accelerator. but curves and ramps could probibly be done by arranging multiple colliders in an arc, disengaging from one and re-engaging the next (snapping to the origin of the next collider), a spline curve might be better if unity supports that kinda thing. in that case the splines would replace the box colliders and you would check to see if you can engage the track with a box-spline collision. if there is no spline object provided by unity i suppose you could use the position of a bunch of game objects to create one, essentially a vertex path with some smoothing function applied to it, or it could be a list of verts from the cfg. an object moving down a spline could snap its orientation based on its tangent vector.

your drawing kinda gives me an idea though, you could probibly integrate the pylons right into the track sections using a similar method to the way the towers from the launch clamps are rendered. when track sections are docked, then the pylons are procedurally created for the segment, at which point it is bound to the terrain like a rocket on its clamps. id probibly go for larger track sections as opposed to smaller ones. 100m sections sounds about right. one big part with no need for strut connections between them (they are docked) and you might load one new segment for every few frames.

Edited by Nuke
Link to comment
Share on other sites

. while an object is engaged to track it is constrained so that it may only translate along the z axis of the collider. if your car's collider exits the rail collider then you become disengaged, and before any physics would be applied it would search for another piece of track to engage.

This sounds like the plan I had for overlapping different parts might work, if it engages on to the next piece of track

your drawing kinda gives me an idea though, you could probibly integrate the pylons right into the track sections using a similar method to the way the towers from the launch clamps are rendered. -snip-

one big part with no need for strut connections between them (they are docked) and you might load one new segment for every few frames.

I think I would to it with just the one part, that has track and viaduct combined. No need to use pylons at all. But maybe having that part generated like the launch clamps would look better than just having it done as a texture.

Earlier in the thread, it was concluded using kerbtown to make the segments rather that having them as parts has a few advantages.

BTW, one of the things that got me thinking about this was Skykooler's Mass Driver mod. And your info on colliders will be very useful should I go ahead and try to make this.

Edited by Tw1
Link to comment
Share on other sites

Got a rough idea what I'd need to do now. Am I right in thinking that the train bogie part will need a special collider of its own that interacts with the track's collider, to engage on the track somehow?

Would the ability to engage or disengage using an action group have to be set up in unity?

Then, I just need to work out if it's better to make the sides of the viaduct as one surface with a texture, or as parts of the model. It's got to look lightweight, but sturdy.

Link to comment
Share on other sites

yea, the trucks (i believe thats the correct train terminology) would need to have some kind of engagement point. it has 2 jobs, to indicate the center origin which must align to the track collider z axis, and to provide a bounding box (in the form of a box collider) so that you can check to see if it is close enough to a track collider to engage its track (if its not already engaged to something else).

not sure about the action groups.

Link to comment
Share on other sites

Ok. I got unity.

I made a very simple test model. I managed to get a box collider on it.

9hrHAjN.png

Ummm...

b7e.jpg

The ladder tutorial suggests something to do with tags and part triggers? The ladder tag seems to be missing.

I do have a prototype model for a viaduct now. Textures are just a placeholder.

It may be a little tall, but you never know what kind of terrain you'll want to cross.

Also, might this be better in another forum now? Moderators, could you shift it somewhere?

Edited by Tw1
Link to comment
Share on other sites

the ladder colliders all have a tag, and i bet that kerbals have something similar. i think if you tag your box colliders (use a tag that isnt used by something else i suppose) then mark the colliders as triggers. supposidly this will let you hook into code that does something useful, either tries to engage the track, or if already engaged, nothing. and there will probibly be another call somewhere that happens every frame, where you can apply physics, theres probibly also going to be an init. this is about the point where you need code.

Link to comment
Share on other sites

On the Kerbal city building thread, nothke raised an alternative idea:

if you really want to make a collidable train, I think this might be a good idea to make it very simple, and as robust and functional as possible, here's a suggestion:

nZcTVMy.jpg

(width/height not to scale)

As you can see, it's more a "guided truck" than a train, but still it follows the "rail" and the colliders are big so there are no problems with them and you can probably achieve high speed. The rails are high and the center of gravity should be as low as possible so that there are no easy derails.

Beside the junctions, the good news is that this system is doable right now without any scripts

This would simplify some things. I'd need more colliders, including those wheel ones I guess, but it would do away with the need for scripting stuff.

I'd either go with a T shaped monorail thing, or a pair of bracket shaped rails, and give the bogie both supporting wheels and horizontal guidance wheels.

This would mean that track segments would have to be closely lined up, but using tapered sections at the end could give a little leeway. Don't know if overlapping collision meshes like that will cause any problems, but leaving a gap won't be good either.

Another disadvantage would be a need for more types of track segment.

At least one curve part, assuming it's possible to place it with either end touching the previous part, or maybe two, a tighter one may be useful in some places. There would need to be at least one angle adjustment part as well.

Extra models mean a less efficient mod, and more chance of bugs. Curves and colliders also make for more complex models.

But, this way has more potential for adding extra things. Someone could script a junction, or make a railyard if they wish, as long as they make the track the right size and shape.

So, what about this other option? What to you guys think/ recommend?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...