truck and trailer

Blitz3D Forums/Blitz3D Beginners Area/truck and trailer

Pete Carter(Posted 2006) [#1]
Just wondering how best to make the cab drive around and the trailer follow in the correct way? they are 2 different b3d models.

the truck in question




jeffmorris(Posted 2006) [#2]
I think that you need JV-ODE add-on because there's a demo program with tractor-trailer.


b32(Posted 2006) [#3]
You could try this: First, use pointentity to point the trailer to the cab. Then, move the entity with the distance between the trailer and the cab (EntityDistance)minus the allowed distance. .. edit: you should use a pivot on the connection point, parented to the cab instead of the cab itself.
ie:
pivot = CreatePivot(cab)
moveentity pivot, 0, 0, 1


Pete Carter(Posted 2006) [#4]
thanks guys

ive been playing with pointentity, but i want the trailer to pivot like a real trailer would in motion. i was hoping not to have to use any physics addons as the programs getting quite complex as it is. ill keep playing. if any one has any examples please post

Pete


b32(Posted 2006) [#5]



Beaker(Posted 2006) [#6]
Nice and simple demo, bram32.


Nathaniel(Posted 2006) [#7]
Hey, that's pretty fun :)


Pete Carter(Posted 2006) [#8]
thanks very much my code was almost the same apart from my align trailer to pivot bit didnt work right with the trailer snapping back to zero rotation. Hehe

Pete


Pete Carter(Posted 2006) [#9]
oh sorry one more thing, in the code above how would you limit how far the cab can turn left and right? to stop the cab passing though the trailer and i want a large turning circle.

Pete


Andy(Posted 2006) [#10]
>Ive been playing with pointentity, but i want the trailer
>to pivot like a real trailer would in motion. i was hoping
>not to have to use any physics addons as the programs
>getting quite complex as it is. ill keep playing. if any
>one has any examples please post

Remember to set the centers of rotation between the back axles of both cab and trailer, that will make them seem more realistic without physics.


Andy


Pete Carter(Posted 2006) [#11]
ive got it looking good with my model but with the code above whats the best way to limit the maximum turning angle of the cab?


b32(Posted 2006) [#12]
For that, this example is better. The other one had the directions messed up a bit.
"Yw#" is the difference in angles between the cab and the trailer. When the cab and trailer align, it is around zero:



Pete Carter(Posted 2006) [#13]
nice example, but what ment was limiting the cabs turning angle so if you held down the left or right key the cab would stop turning before passing though the trialer. say at about 45 degrees


b32(Posted 2006) [#14]
What I ment to say was, to achieve that, the difference between cab and trailer angle should be limited to -45..+45.
Try this in the main loop:



Pete Carter(Posted 2006) [#15]
thanks works great going forward reverse really screws it up, this is harder than i thought. ill keep playing with your code. thanks again bram32