btRaycastVehicle roll after collision with wall
-
- Posts: 3
- Joined: Fri Aug 31, 2018 11:44 am
btRaycastVehicle roll after collision with wall
If I keep steering right, the vehicle will roll like shows in picture.
I guess this is becasue after collision the wheel which touch road still apply right impulse to car.
I hope the vehicle always keep horizontal or flick horizontal.
How can I fix this problem or how can I achieve a anti-roll system?
You do not have the required permissions to view the files attached to this post.
-
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: btRaycastVehicle roll after collision with wall
I have one idea you could try:
Give the vehicle a very low center of mass (COM). It is pretty easy to do this by wrapping your existing shape with a btCompoundShape. You can even put the COM outside the bounds of the body, below the wheels, which would make it automatically self-righting (unflippable).
Give the vehicle a very low center of mass (COM). It is pretty easy to do this by wrapping your existing shape with a btCompoundShape. You can even put the COM outside the bounds of the body, below the wheels, which would make it automatically self-righting (unflippable).
-
- Posts: 3
- Joined: Fri Aug 31, 2018 11:44 am
Re: btRaycastVehicle roll after collision with wall
Thanks.
I tried set the center of mass lower, and it works in most of case.
And there's another question, when car collide with wall at a high speed, especially car's direction perpendicular to the wall. The car will fly a liite, maybe just 10cm above ground, and rotate around Up-Axis a lot quickly, sometimes almost 360°, then fall to the ground.
How can I prevent car bounce to air or not rotate too much?
What I want is the car bounced horizontally and wheels still contact with ground........
I made a video to show the situation
https://youtu.be/9T3_QUOK-sU
I tried set the center of mass lower, and it works in most of case.
And there's another question, when car collide with wall at a high speed, especially car's direction perpendicular to the wall. The car will fly a liite, maybe just 10cm above ground, and rotate around Up-Axis a lot quickly, sometimes almost 360°, then fall to the ground.
How can I prevent car bounce to air or not rotate too much?
What I want is the car bounced horizontally and wheels still contact with ground........
I made a video to show the situation
https://youtu.be/9T3_QUOK-sU
-
- Posts: 849
- Joined: Tue Sep 30, 2014 6:03 pm
- Location: San Francisco
Re: btRaycastVehicle roll after collision with wall
The extra low center of mass (COM) might be contributing to its "hop" into the air on collisions. Maybe try dialing it higher to see how it affects that problem. Perhaps there is a sweet spot for how low to make the COM.
Dunno if these other ideas will work but they are what I would try:
(1) Increase the car's inertia tensor(2X? maybe 4X?). This will make the car much harder to get spinning. On the other hand, once it starts spinning this will make it much harder to stop.
(2) In combination with (1) increase the car's angular damping. This should help the car stop spinning even when it has an unreasonably large inertia tensor.
(3) Lower the car's restitution to 0 (if you haven't done so already). Maybe also lower the restitution of the walls to 0 as well. This will make collisions less bouncy.
(4) Increase the gravity on the car to be high (2x? maybe 4X?). This will make it harder for it to jump into the air. However, if you want the car to be able to make jumps in the game you might need to keep the gravity high when rolling but dynamically reduce it to be normal or even lower than normal when it starts a jump.
Dunno if these other ideas will work but they are what I would try:
(1) Increase the car's inertia tensor(2X? maybe 4X?). This will make the car much harder to get spinning. On the other hand, once it starts spinning this will make it much harder to stop.
(2) In combination with (1) increase the car's angular damping. This should help the car stop spinning even when it has an unreasonably large inertia tensor.
(3) Lower the car's restitution to 0 (if you haven't done so already). Maybe also lower the restitution of the walls to 0 as well. This will make collisions less bouncy.
(4) Increase the gravity on the car to be high (2x? maybe 4X?). This will make it harder for it to jump into the air. However, if you want the car to be able to make jumps in the game you might need to keep the gravity high when rolling but dynamically reduce it to be normal or even lower than normal when it starts a jump.
-
- Posts: 3
- Joined: Fri Aug 31, 2018 11:44 am
Re: btRaycastVehicle roll after collision with wall
Hi, drleviathan.
Thank you very much!
I tried your suggests.
(1)Increase car's inertia tensor looks not naturally and not easy to tuning parameters.
(2)Increase car's angular damping have no effect.In fact, I use emscripten compile bullet to javascript, so it's hard to debug what's wrong.
(3)I use default restitution, it's 0.
(4)I have a similar idea, I modifed btDefaultVehicleRaycaster not raycast wall, check every wheel is isInContact, if isInContact==false apply a down impulse at wheel position, but seems hard to measure how many impulses should apply. I think this maybe the feasible method, I have not implement it yet,because now I have another problem.
For achive drift,I add some code like this:
If I keep drift, the car will rotate around a point circle by circle.But If I lower COM, the car will out of controll when drift. So what can I do now. Achive drift use applyTorqueImpulse?
I test again, if I set simulation step to 0.167, 60 FPS,the car will stable when drift.If I set simulation step to 0.1, 100FPS, the car will not stable.....
still need some methods to make car more stable.
Thank you very much!
I tried your suggests.
(1)Increase car's inertia tensor looks not naturally and not easy to tuning parameters.
(2)Increase car's angular damping have no effect.In fact, I use emscripten compile bullet to javascript, so it's hard to debug what's wrong.
(3)I use default restitution, it's 0.
(4)I have a similar idea, I modifed btDefaultVehicleRaycaster not raycast wall, check every wheel is isInContact, if isInContact==false apply a down impulse at wheel position, but seems hard to measure how many impulses should apply. I think this maybe the feasible method, I have not implement it yet,because now I have another problem.
For achive drift,I add some code like this:
Code: Select all
if(m_drifting)
{
btVector3 sideImp = m_axle[wheel];
if(wheelInfo.m_bIsFrontWheel)
sideImp *= m_driftFrontSlip;
else
sideImp *= m_driftBackSlip;
m_chassisBody->applyImpulse(sideImp,rel_pos);
}
I test again, if I set simulation step to 0.167, 60 FPS,the car will stable when drift.If I set simulation step to 0.1, 100FPS, the car will not stable.....
still need some methods to make car more stable.