truck and trailer
Blitz3D Forums/Blitz3D Beginners Area/truck and trailer
| ||
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 ![]() |
| ||
I think that you need JV-ODE add-on because there's a demo program with tractor-trailer. |
| ||
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 |
| ||
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 |
| ||
|
| ||
Nice and simple demo, bram32. |
| ||
Hey, that's pretty fun :) |
| ||
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 |
| ||
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 |
| ||
>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 |
| ||
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? |
| ||
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: |
| ||
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 |
| ||
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: |
| ||
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 |