Games [XUI2D] Monster Truck Example - WheelJoint

Erel

Administrator
Staff member
Licensed User

The WheelJoint is similar to a RevoluteJoint with a spring that allows the bodies to move along a defined axis.

The movement is done by enabled the joint motors.

If you run it with debug drawing enabled you will see two additional fixtures:



The bottom one is a heavy fixture that helps with stabilizing the car. It is destroyed after 100 meters to make the car crash.

The top one is very light and it used to find out when the car rolled over.

Getting the physics to behave nicely was challenging and it still needs a bit fine tuning.
There are many parameters that affect the behavior. The hills in this example are too steep. It would have been better to use different tile set with more gentle heels.

The example will be added to the examples pack.
https://www.b4x.com/android/forum/threads/xui2d-example-pack.96454/

Tileset credit: http://www.kenney.nl
 

sorex

Expert
Licensed User
Great!

What is wonder is if you need to set a maximum left/right rotation angle on the springs.
The wheel would go over the car otherwise, not?

Is there a specific reason why the car polygon doesn't go around the car (car+wheel caps) only? (not including the wheel centers)
 

Erel

Administrator
Staff member
Licensed User
What is wonder is if you need to set a maximum left/right rotation angle on the springs.
The wheel would go over the car otherwise, not?
The joint allows the wheel to turn around themselves. They will not be able to turn if there were limits (this is why there is no limit feature in WheelJoint).

Is there a specific reason why the car polygon doesn't go around the car (car+wheel caps) only?
You should try it. If the car polygon is too low then it will hit the ground.
 

sorex

Expert
Licensed User
I will play around with it.

Thanks for the new 0.98 Xui2D update (which is required for this).
 

sorex

Expert
Licensed User
I ran it last night and it's very smooth & realistic, well done.
 
Last edited:

LucaMs

Expert
Licensed User
For the moment I have not used XUI2D, so my question is certainly not very inherent the topic: the poor quality (resolution) of the vehicle to what is due?
 

wyatt420

Member
Licensed User
how can you check the truck is on the ground? do you need to add sensors to the wheels and check wheel/ground collision?
 
Top