Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decreasing the number of Fixed Timesteps causes the vehicle to jump finely #44

Open
pspkurara opened this issue Jan 9, 2020 · 6 comments

Comments

@pspkurara
Copy link

pspkurara commented Jan 9, 2020

I don't know the cause, but as the title says.
Validated to reduce to save CPU because too many initial values.
If me reduce it a little, a small amount of shaking will occur.
Reduce it in half and the vehicle will start to jump
Will not stay still properly.
This also happened when trying to port Rigidbody's AddForce to Jobsystem Update to speed things up (due to structure, probably skipping some frames).
What approach can I make them lighter?
Is there any way to reduce the number of Rigidbody AddForce?

I feel this asset is great and I'm creating more realistic vehicle behavior while customizing it from the era of Asset Store.
I don't want to consider stopping using this asset whenever possible.
Please give me an idea.

@JustInvoke
Copy link
Owner

The vehicles should remain stable with timesteps as large as 0.02, but lower than that can cause issues because forces are designed to scale with the timestep length to maintain consistent behavior.

Raycasts have the greatest impact on performance out of everything in the project. One way to reduce the frequency of wheel raycasts is to use the wheel groups feature on the VehicleParent script. This is copied from the manual:

Each wheel group represents one fixed update and each wheel in the group will fire their raycast during their fixed update. For example, if there are 4 groups, each one containing a single wheel of a car, it will take 4 fixed updates for all of the wheels to check for their collisions. This can greatly improve performance at the cost of precision, so it should be reserved for AI vehicles.

@pspkurara
Copy link
Author

pspkurara commented Jan 15, 2020

I tested using wheelgroup.
However, it did not work properly, as the vehicle's body did not float properly and was buried up to the collider position on ground.
Is there a reference for the correct setup of wheelgroup?
No sample prefab was found.

I tested the setup as follows.
plz any idea.

  1. Set 4 existing wheels in wheelgroups

  2. a. Wheels is an empty array -> tested, and failed

  3. b. attached one copy of the existing wheel installed in the center of the vehicle (with suspension) -> tested, and failed

@JustInvoke
Copy link
Owner

Sorry for the late reply, I've been busy with school.

Take a look at the wheel cast mask on the global control object/script, it sounds like the wheels might be ignoring the layers that your environment objects are on.

@pspkurara
Copy link
Author

np man

i was checked, but it is not.
It is true that Vehicles and LayerMask on the ground are ON, and the others are OFF.
do you have a correct sample?

@pspkurara
Copy link
Author

Did I come up with any other approaches to using WheelCollider's instead of Wheels, or have any ideas?

@JustInvoke
Copy link
Owner

You probably want to have the layermask include the default layer so that wheels can hit everything. You can look at the sample scene for an example. The wheels array should contain all of the wheels of the vehicle. There is a "Get Wheels" button in the inspector that you can use to fetch them. Creating a new wheel in the center of the vehicle is not a good idea since vehicles are not designed to work like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants