godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.19k stars 21.21k forks source link

[Bullet] Wrong physics when accelerating and braking using VehicleWheel #34856

Open JustElectron opened 4 years ago

JustElectron commented 4 years ago

The spring physics of the vehicle wheel or body is wrong. When accelerating and braking, the vehicle tilts forward or backward. However this is done in the opposite direction from what is natural. Using a simple setup with a vehicle body and 4 wheels and a static ground plane.

Here is an example of a vehicle braking Capture

KoBeWi commented 3 years ago

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

angad-k commented 3 years ago

Couldn't reproduce the issue in 3.2.3. Tilting works well. Recording :

https://user-images.githubusercontent.com/54415525/110321977-7090e500-8038-11eb-8943-bf920f822dd5.mp4

KoBeWi commented 3 years ago

So closing as resolved. If you can still reproduce in Godot 3.2.4 rc3 or newer, comment with a reproduction project.

IvailoBurov commented 3 years ago

For me, this problem exists in all versions, including 3.3.3. I'm attaching a video. The BastiaanOlij project can be used for a test project, where the horizon changes downwards during acceleration: https://github.com/BastiaanOlij/vehicle-demo/tree/Part-4

https://user-images.githubusercontent.com/63282037/133959509-45662d06-ec57-4566-b424-3800c5135dbe.mp4

If necessary, I could do a separate project, but I use Bastian's code here.

KoBeWi commented 3 years ago

Reopening as per above comment.

mojoyup commented 2 years ago

Same for me as of now. Version 3.4.4 Steam version. I used my own code, so its not the coding I imagine.

Calinou commented 2 years ago

@mojoyup Please upload a minimal reproduction project to make this easier to troubleshoot.

mojoyup commented 2 years ago

@mojoyup Please upload a minimal reproduction project to make this easier to troubleshoot.

Interestingly, I created a simplified test project, same version and it seems to work. I will try to find out in my original what could have caused this and report back, in case anyone has this issue also.

What happened with mine was, when I was changing the VehicleWheel Radius (I scaled everything down, even the models/meshes), then it seems to be "backwards".

The project before scaling and resizing the VehicleWheels worked but Ill try to get more details for it if needed.

mojoyup commented 2 years ago

VPTest.zip This is the test file. This works if anyone wants to use this

Zireael07 commented 2 years ago

Rule of thumb for physics bodies/collision shapes is NOT to scale them!

mojoyup commented 2 years ago

The VehicleWheels have the option for such in the parameters. The others were not scaled in the editor, but in Sketchup. EDIT: Meaning that they have the resize parameter. Sorry I didn't specify. EDIT2: I checked just now that all of the Transform scales were not messed with and they are all at "1". So that's good. Good point btw too!

mojoyup commented 2 years ago

I think I might be able to ahve this closed. I figured out one thing that affects the physics this way. It is the different in the transforms of the parent node (Vehicle), and the children nodes (most likely and mainly the wheels and main collision). I have always put my origin of the children nodes to where the parent node sits on the ground for better control. If it is too exotic of a difference between the parent node Y pos and the children Y pos', Itll start to behave different. I hope that makes sense.

TL/DR: Try to reset the transforms of the children and the parent node(Vehicle) and test/tweak.

UPDATE NOTE: If the VehicleWheel(s) combined y transform is higher than the VehicleBody y transform, it's likely this phenom will occur. Either make the VehicleWheel(s) y transform == VehicleBody y, or make them lower. NOTE: Too low without the proper settings, will cause the wheels to go into the ground/mesh/collision.