Hi there, is it possible to have a square wall placement?
Suggestion: Square high walls placement
Its possible, and I'd like to, but I don't understand math enough to do this
Looking at the plugin, which admittedly I don't do C#, it looks like you're deriving a circle from where the player is looking and the radius. We can take that circle and derive a square, of the same area, from the information available. I made a couple sets of code, in Python and MATLAB, to demonstate this being done. I'm just taking a stab at this as I thought this might be cool as well. The pastebins are linked below:nivexIts possible, and I'd like to, but I don't understand math enough to do this
Square from Circle (Python)
Square from Circle (MATLAB)
Example Plots:



interesting, thank you. I will translate it into c# and try it out when I have some time :)
Im so happy right now ...
I've been playing around with this since yesterday, and I have a method for doing a square. Admittedly, I'm just replacing the circle for testing. It's only doing the 4 corners right now, but it's rotating appropriately. I just wrote something in MATLAB today to determine the incremental points on the perimeter (like how it's done by degrees on the circle). I'll be converting those to C# later tonight (hopefully), and then doing some testing to see if it makes a square. If successful, I'll do some cleanup and post it here for @nivex's review.
nice thanks!
I have it all working except for one thing. When doing the circle, it uses the following code to change where the walls are looking:
entity.transform.LookAt(center, Vector3.up);With the square formation, I'm going to need to figure out how to tell where the walls should be pointing based on their side. I'm still mulling over some options, so it's not a dead end yet. wall.transform.rotation = Quaternion.LookRotation(dir);
just need dir, I think
I have them rotating, but I still have some issues with the angle if it's not pure N/S/E/W. I'm continuing to debug. However, there's some image previews below. I also have some flaws where the height gets messed up. I've included those as well in case someone has an idea. I'm choosing the height the same way the circular walls were currently. I'm guessing that the center points overlap sometimes and it picks a height on top/under the wall when that happens.
If you'd like to see the code @nivex, just let me know and I'll send you a DM with the pastebin. It's too dirty to share here right now.


it's coming along really nicely. great progress! I don't recall off hand, but I think the CreateZoneWalls method in Raidable Bases is a bit different if you want to compare them.
sure, I can take a look at the code but I doubt I'll be of much help. would like to see it regardless though. maybe I can give some feedback at least
Though I've had limited time the last couple days to work on this, and lots of attempts at different methods, I have the walls staying square no matter where I look now. However, I have something odd happening now, and I'm not sure why. It's likely a math problem that I'll have to correct, but in between each 45 degree increment, the direction your facing spawns the corner of the square instead of the center of the first side. This means that if you're not facing N/NE/E/SE/S/SW/W/NW, it will be rotated 45 degrees. I'm going to stop poking at the math at this point, and work on the separation between circle and square walls so that we can do both. Then I'll publish what I have before I circle back around.
sounds interesting. thanks.
Here's the code:
Square Arena Walls
I've noticed 2 things that still need fixing. The rotated arena issue at certain angles, and at larger wall size, there's a gap in the corners. I tested at a radius of 20, and it works fine there. I'll troubleshoot it more in the coming days if no one else figures it out. However, things are working here enough for people to play around with it.
@nivex,
Feel free to edit, move, or change anything. I'm just translating experience from other languages over to C#/Unity, and sometimes it's a learning experience. Any feedback is welcome.
awesome, will check it out soon!
- 1
- 2