Easiest way to push train cars

Blitz3D Forums/Blitz3D Programming/Easiest way to push train cars

asdfasdf(Posted 2005) [#1]
What is the easiest way to push some train cars up a slight hill, have switch and curves? I'm trying to have some cars go up to a dock.


GfK(Posted 2005) [#2]
What is the easiest way to push some train cars up a slight hill, have switch and curves? I'm trying to have some cars go up to a dock.
I don't quite understand....


asdfasdf(Posted 2005) [#3]
How could you have a train engine push about 50 cars up hill and stop once the cars reach the end? There are 4 tracks on the dock so I need to be able to have switches. How could do this with as little coding as possible? Didn't somebody make a train simulator in Blitz3D?


Ricky Smith(Posted 2005) [#4]
If you want to incorporate real world physics into your game then have a look at the Tokamak or ODE physic libraries.

http://playerfactory.proboards25.com/


asdfasdf(Posted 2005) [#5]
Couldn't you use collisions to keep the train from falling through the tracks and use that for weight pushing down on the engine?


Rook Zimbabwe(Posted 2005) [#6]
yep I can see that. Blitz Programmer has the idea. You need to model the tracks and the cars so that hey cannot go off the tracks. Set the cars for sliding collisions on the tracks and code in some sort of primative gravity / reaction engine into your game. Probably based on the pool game reactions code or ODE physics libs...

Gonna be a difficult thing to do for a first time go... I would take it in little steps of problem solving... I come up with a lot of little game ideas that way! :)

RZ


Rhyolite(Posted 2005) [#7]
Hmmm, you could just use Blitz collisions and MoveEntity commands. Using a physics engine might add some extra realism, but adds more complexity.

I think all the physics engines are represented here:
http://www.blitzbasic.com/Community/topics.php?forum=94

You need to consider how if you are going to use 'collisions' (either Blitz or other) to hold the train wheels onto the sides of the track. This would be like a real train and it would follow the rails through points etc.

Or you create a 'path' on your 'world map' which the train follows and you can forget about gravity and collsions.

As suggested above, do not launch yourself straight into the game code, try stuff out first.

Rhy :)


Ross C(Posted 2005) [#8]
I think the waypoint path is a better idea. What you could do though, slightly trickier, is, create an invisable wall the runs alone the course of the track. Grab the normals the wall at the trains current position, from the side, AlignToVector using that, then grab the normals from the gradient of the hill, using a line pick or such. THEN, save the rotational value for the Y axis, align to vector on the hill, and rotate the Y axis back to what it orginally was :o)

I'll try and put together some code for this.


Ross C(Posted 2005) [#9]
This isn't the pushing train carts part, but it makes the train follow a train track type mesh and align to the ground too. I've tried to comment the best i can :o)

http://www.rosscrooks.pwp.blueyonder.co.uk/traintrackfollow.zip

The train unfortunetly rotates 90 degs on it's side though, due to the linepick coming form the left, and not the top. I suppose all you would need to do, is adjust the normal the pick returns, or rotate the train mesh 90 degrees :o)


Rook Zimbabwe(Posted 2005) [#10]
Ross that is really a good idea... pathing would indeed be much simpler... Is there some sort of B3D map path creator tool??? You know... you load your map and you can create a path for meshes to follow??? OR set points so you could randomly follow one of several path points?


asdfasdf(Posted 2005) [#11]
Ok Thanks for the code Ross C. It looks like you code would be the easiest to use.


asdfasdf(Posted 2005) [#12]
I have the terrain in one 3ds file and the the dock in another.