|
Hi, I have an application that adds and removes colliders from a parent object at runtime. It does so in the Update method. However, sometimes after this occurs the GameObject stops responding correctly inside of the physics engine and it simply falls through the floor. However, if I edit the location of the GameObject with the Unity Editor the physics engine get's back on track and then collides with the floor as you would expect. Do I need to do something to the physics engine to refresh it or alter it that things have changed? Do I need to pause it while I make changes? thanks!
(comments are locked)
|
|
Then the problem might be:
Without more description of what is going on, I can't think of another possibility. It was related to moving it by positioning and changing the parenting at runtime.
Sep 21 '12 at 08:26 PM
madmik3
(comments are locked)
|
|
Consider using the Also note that adding/removing collider at runtime is a pretty expensive operation, so do not overuse it. thanks for the reply. I don't do it very often so it's not a problem. However, FixedUpdate does not solve the problem. Will keep working at it.
Jul 20 '12 at 09:29 PM
madmik3
(comments are locked)
|
|
Agreed, there may be a better method to accomplish whatever it is you want to do... Anyway, your collider is being instantiated so that it's intersecting with the floor, therefore not colliding with it. Your method to edit the location gets it back on top, so it works.. or just instance the collider always above the top of the floor collider.. The object is not intersecting the foor when it's changed. It intersects the floor after that point and simply falls though it.
Jul 20 '12 at 02:24 PM
madmik3
not the object, the COLLIDER say my guy is standing on the ground, his capsule or collider is right up against the ground collider. Then I remove the collider and immediately replace it.. But in that one frame, things changed slightly, there's a chance my new collider is EVER SO SLIGHTLY intersecting the ground.. Then of course, there is the question, how does the new collider differ from the old (I assume it's different, otherwise why change?)
Jul 20 '12 at 10:39 PM
Seth Bergman
neither the object nor the collider is intersecting the floor and or anywhere close at the time of change. it later falls through the floor.
Jul 23 '12 at 07:05 PM
madmik3
(comments are locked)
|
