Hi, I'm trying to implement periodic boundary conditions in Unity. Question 1: Is there a possibility to use an additionally collision condition (to sphere colliders/rigidbodies)? In my case an additional distance where sphere-colliders can collide. Or should I write an extra collision script? Would you recommend to measure the distance with Physics.Raycast? Question 2: I also tried to implement periodic boundary conditions via Instantiate (I modified the rigidbody.velocity after each collision for both copies) - But I don't know how to clone a gameobject with exactly the same properties (at distance +- length) for all times. Hopefully Unity has a solution for this problem.
Welcome to the forums! Maybe you're overthinking it a bit. Since objects with RigidBodies use the all colliders attached to the same object and any of their children, you could try having an empty GameObject as a child of your object with colliders attached that match this extra condition you want. Start with it disabled, and when you need the collision boundary to change, enable the child. Then disable it again as needed. I've not tried this myself, so I don't promise it'll work, but it's worth a shot. Give it a try and let me know if it has any problems. Good luck!
Thanks. Using "freeze-rigidbody" it seems to work well. But: My parentobject has a rigidbodies for "freeze-rigidbody" (so the whole system can't rotate around some point) and later for some external forces; My childobjects have rigidbodies and colliders (I think the rigidbodies are needed because with "freeze rotation" collisions don't work properly). But with that hierarchy no collisions happen. I found is this: "When a collision occurs, Unity will search up the hierarchy for the nearest Rigidbody". Any idea how to solve this problem?
I think perhaps I don't understand what you're actually trying to do here. Could you go into a bit more specific detail about what, in your game's terms, you're trying to make happen?
https://www.nationalgeographic.com/...8/13/shadeballsgallery/2shadeballsgallery.jpg Using a physic material without friction has bypassed the problem. Later I need the collision to happen with friction; so at some point I want both childs to spin independently from the parent. I'm simulating spheres on waves. To improve performance I "folded" the surface to a torus. If a sphere collider leaves the plane, a new one will be instantiated. My hierarchy for now: parent(rigidbody(with freezed-rotation)/affected by waves/gravitation) --child1(sphere collider) --child2(sphere collider) For not to big densities it seems to work quite well. Thanks a lot for your hint.
I think I'm at the limit of what I can do for you, because I don't understand any of that! Sounds like you're on the right track, though!