- Home /
RigidBody vibration on Terrain?
Salut!
I have this problem with Unity3D 5.1.2f1:
http://youtu.be/y4pkJMU8wXc (watch since 0:0:10).
The scenario of video is: start the game, apply controls and watch tank positions, then release controls.
This video is captured from Editor screen, so no camera shaking is related to this issue.
The script I use is here:
The situation briefly:
1) I have my armour shaking infinitely on some terrain positions. The armour can vibrate or can stand still, depends on things unknown to me. Must move several times to see the effect.
2) RigidBody parameters of all three tanks are the same:
Mass = 30000;
Drag = 0.1;
AngularDrag = 4;
UseGravity = true;
IsKinematic = false;
Interpolate = whatever possible variants, does not matter;
CollisionDetection = whatever possible variants, does not matter;
Constraints = RigidbodyConstraints.None;
2) I used transform.Translate/Rotate, I used RigidBody.MovePosition/MoveRotation, I used RigidBody.ApplyForce/ApplyTorque: no difference in the result.
I used Update() and FixedUpdate().
Any variant gives armour vibration.
3) I have tried all PhysicMaterial combinations between Terrain and Armour. I tried absence of PhysicMaterial too.
I have tried to tweak Physics\Bounce Threshold, Sleep Threshold etc.
4) However, if the armour starts on the Cube (you can see it is on the right of video), the RigidBody behaves well without any vibrations or shaking.
Terrain is just plain 2km*2km and with standard grass texture. Nothing more.
Whatever I do, the bug is here. The more complex project becomes, the more amplitude of vibration is and more often vibration comes (up to constant vibration).
It looks like bug appeared in some 5.1.1 or 5.1.2. I haven't encountered it earlier.
Here is the project https://www.sendspace.com/file/yegx5h
What can I do to eliminate this shaking/vibration?
Thank you!
Possible because whatever you use too move/rotate the tank, gets called every frame and its float value never equals zero so its shaking. You can set its Rigidbody to $$anonymous$$inematic if there's no user Input. Or use Velocity to move the Rigidbody. I'll setup a teest scene now to check it out.
I tried AddForce(Force$$anonymous$$ode.VelocityChange) too. Shaking bug encountered.
I tried to make RigidBody $$anonymous$$inematic = false, apply transitions, then $$anonymous$$inematic = true. The only result is the tank falls from the platform very slowly (it looks like gravity decreased).
I tried
if (!$$anonymous$$athf.Approximately(velomod$$anonymous$$yDriveNew, 0)) //execute motion.
as you suggested. No result. RigidBodies still can vibrate infinitely.
Hmm. Can't seem to replicate the issue with a Cube or a quickly made tank in 3ds max (A cube and something that looks like the wheels etc...) If I got anything will let you know. The script works fine here btw (Unity 5.1.1f1)
https://www.sendspace.com/file/yegx5h These are not quite $$anonymous$$e, they're Inspond's, so I don't quite have the right to distribute them as a product ;-) No, wait. I can!
The shake happens cause the rigidbody still gets transform position / rotation force from Fixed Update. You can avoid it with something like this (bit dirty solution tho):
void Update()
{
if(Input.GetAxis("Vertical") != 0 || Input.GetAxis("Horizontal") != 0){
this.GetComponent<Rigidbody>().is$$anonymous$$inematic = false;
}else{
this.GetComponent<Rigidbody>().is$$anonymous$$inematic = true;
}
}
Your answer
Follow this Question
Related Questions
How to make Rigidbody detect collisions but stop its movements 1 Answer
Elevator vibrating!!! 1 Answer
Multiplayer Rigidbody Vibration 2 Answers
rigidbody vibration 0 Answers