- Home /
Collision problem
I'm trying to make a remake of a game on the ps2 in unity using C# and one of the objects within the game acts very strangely to me at least but I don't know how to recreate it in unity.
Lets say there is 3 of these objects, 2 at the bottom and one on top of the two. The objects will always look at the player when they come close but when they rotate, they never collide with each other so my guess is they are set to not collide with the same object but collide with the player. Though that doesn't make sense as the object balancing on top of the other two is perfectly fine, so there must be collision or else that top object would just fall through the other two below it.
My guess at first is that the objects had no gravity but that must also be wrong since if you destroy the two blocks under the top block then the top block will fall down.
Does anyone have any idea how i can do this in unity?
What exactly do you mean when you say they don't collide with eachother?
I mean they don't interact with each other, so they go right through each other when rotating ins$$anonymous$$d of hitting each other. But the top object ins$$anonymous$$d sits perfectly on top of the bottom two objects and doesn't go right through them.
Is it possible for one of these things to move completely through another in the horizontal direction? It sounds like the collider is just smaller than the model, so the geometry outside of the collider won't halt the rotation.
Hi try to explain a bit better what is going on, what you want to achive. A screenshot would help as well. Sounds like a problem that should be solvable if I know what the actuall problem is.
I believe the issue was resolved already as a Best Answer was already selected by the OP. Also, if you expand the replies to the comment above you'll see that there are screenshots and more info too.
Answer by LazyElephant · Dec 11, 2015 at 05:11 AM
You could make this happen using multiple colliders. Add an Empty game object as a child of the object and add a box collider to it. Shrink the collider on the object and the empty game object and move them so they look like in the picture.
The next step is to create 2 new layers, one for the empty and one for your game object. Go to Edit->Project Settings->Tags and Layers and add two new layers.
Assign one layer to each of the objects, then go to Edit->Project Settings->Physics and change the collision matrix so the layers collide with each other, but not with themselves.
That will allow them to rotate without colliding with each other, while still being able to stack.
Answer by Rad-Coders · Dec 10, 2015 at 10:36 PM
You shouldn't change the transform of the object. Rather use the physics engine, so use add torque or use a motor.
Answer by dhore · Dec 11, 2015 at 01:53 PM
I'd say you just want the bottom two that are next to each other to not collide (so that they can turn "through" each other) but still have the top one collide with both of the bottom ones. This is really easy, just tell the physics engine to ignore collisions between the 2 bottom objects using Physics.IgnoreCollision