- Home /
How to detect when two colliding objects create a corner?
Well if you look at the screenshot, I would need that corner to look more like a corner, my idea is to be able to make walls dynamically in game time but without using connectors like the posts of a fence, looking more like a smooth wall. The wall is composed of 3 parts, the two faces that are seen and an upper face for a perspective view, would have a total of 3 planes. I try to detect the face that collides with the panel collider but the script does not work very well. It does not do what I need technically. The idea is that, when I can detect the corner, I can decide what to do with that information. In any case could replace the affected models to close the corner. Also could apply another type of solution, the problem is that, I do not know how to detect that these two objects create a corner.
Edit:
Well, studying the grid topic a little, I realized that this was not going to be useful so I completely redo it. Now each vertex of the grid, each point, is formed by a gameobject which can store information. So far I can say that I store a wall and the points to which it connects. Even so I was thinking that this became very tedious and I do not think it will be useful either, so before going any further, I would like you to give me some tips on this. My idea was that each connected point provides information on whether it has a wall or not and to which points that other point is connected, to know if a corner is created or not. Then I found the possibility of adding another type of wall, such as a fence, but I thought, if the wall was not a wall, and this was a fence, and this was between two walls, I would know if it is a wall or If it is actually a fence. Then I came up with the possibility of adding sub-grids where the walls would really be stored, and I found that I would need a total of 4 grids, one to navigate the poles that create the walls, another 2 for the walls, and another For objects that I will add as a box or barrel, etc. And this leads me to not know if what I'm doing is fine or if I'm complicating it more than it really should be.
Depends on how your wall placement works... If it is freeform and you can place anything anywhere, I can't help you right now. However, if you use some kind of snap-to-grid system, and it looks like this on the screenshot, then you could store the information of a particular grid point when a wall is placed there and use that to compare is with it's neighbors to find out if a wall is perpedicular to it.
I like it, it's a good idea, thank you !!. Yes, I'm using a grid to place the walls. I think it's seen somewhere, a guide to work with dots and place figures with them. I will investigate about it and apply it. It could also be used to store other types of objects that I place using the grid. Although I will see it later...
Answer by Manpreet_96 · Jun 25, 2017 at 04:42 PM
Well, let's see @Ancard, what could be the easiest way to do this? One suggestion I have is putt Raycast from Top left corner of front wall (I am taking this pic as reference to explain my point) , going all the way down along the edge. And the second Raycast from top right corner of the other wall going all the way down the egde. When the raycast detect a collision, you will know it has formed a corner. This may not be very convincing but it's just a thought. Try to implement it.
Your answer
Follow this Question
Related Questions
help with enemy health script 2 Answers
How to move the object to where the object is already pointing to? 1 Answer
Character not jumping high enough 1 Answer
Having difficulties making a block be a death trigger for a ball. 2 Answers
How do I destroy a game object my character hit ONLY if a condition is active? 2 Answers