- Home /
Why are my collisions adding massive amounts of force?
I have a prefab that is cloned repeatedly to make a ground upon loading into the game. No issues there. When you right click, more clones are instantiated at the mouse location. This is where the problem occurs. The player runs around on the ground objects just fine. But if the player gets near the mouse instantiated objects or god forbid, touches one, a massive repelling force is applied, and not always after a collision. You can't get near the new objects. The force is applied pre-collision and creates an buffer or shielding effect. Were you to actually make contact you are thrown across the map. What causes this?
The force is always applied on only the X axis. It doesn't always happen with the first 1 or 2 blocks placed. Are the physics being broken all of the sudden? Has anyone ever experienced this or read about it somewhere else?
The player has a Rigidbody (Mass 0.1) and a Capsule Collider. The prefab has a Rigidbody (Mass 1) and a Box Collider. The details of the prefab are identical to both loading time clones and the mouse click clones in every setting from Rigidbody settings to Box Collider settings.
Any theories are much appreciated. :D
No clue, I am using a similar system in a crate fighting game I am messing with. $$anonymous$$y player has a $$anonymous$$ass 1 $$anonymous$$inematic Rigidbody, and the crates are about half the default block size with a non-$$anonymous$$inematic Rigidbody with a mass of 1. Is your player $$anonymous$$inematic?
Adding $$anonymous$$inematic does indeed remove the issue, but it also removes the the effect of gravity on the player, which I don't want.
Answer by MiraiTunga · Jul 06, 2013 at 05:56 PM
when you instantiate the objects makes sure you give them the right values ..e.g mass ,drag,use gravity and if it continuous or discrete , also check your scripts if there are fixdupdate or just update
I am fairly new to Unity still, but why would switching from Update to FixedUpdate make a difference with collisions? I am using no forces other than gravity. $$anonymous$$y player moves via Translation.
Also, Unity seems to outright ignore the settings I apply to the prefab. All of the physics settings are correct on the blocks vs the prefab blocks. The player as it turns out, the mass of the prefab is set to .1, the player it creates is changed to .25.
Edit: Also, what physics force on a Rigidbody/Collider would apply at over 3 grid distance? and only after 2 or 3 blocks have been placed.
are you adding force in code ? if u are you shouldn't unless you want special collisions that react in a certain way ...also the player shouldn't be changing to 25 suddenly
Well I haven't been able to get Unity to create clones from a prefab that keep all the original values. Unity seems to just ignore the values. I have to use Quaternion.Euler(0, 180, 0) because it ignores the rotation information on the blocks when using Quaternion.Identity. $$anonymous$$ost other values seem to have stuck for the moment, but they change somehow.
I am using no forces at all in code.
try setting up the prefab script so that its gives everything the right values in Stsrt() ins$$anonymous$$d of update so that when the prefab swaps start gives it the right values...check if ur scrpit is forcing this values i.e 25
I had posted a probable solution that I was going to test before closing this, but user Benproductions1 deleted it and wrote me a nasty gram:
"Saying that you will leave a question unanswered, in an answer to the question is fucking stupid. Please repost as a comment."
Perhaps I should have posted the answer without testing to be sure it was correct and left out the details. This forum is a very hostile place it would seem.
Answer by JonnyHilly · Jun 10, 2015 at 05:54 PM
I had the same issue yesterday.... a truck with no forces apart from gravity, just a box collider and 4 wheel colliders... as soon as it touched the floor, it would rotate, accelerate sideways and fly off up into the sky, pretty awesome and funny... but not very truck-like behavior.
Sooo... what fixed it ?... removed my code that was setting the center of mass... and just let the rigidbody set it, itself.
Turn off any scripts you are running, and make sure the rigidbody behaves as expected "without any other code/scripts running..". drop the object onto a slope or some random objects to test.
Also try not to mix character controllers with physics based rigidbodies...