Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by aimmmmmmmmm · May 03, 2016 at 04:36 AM · c#proceduralrtstycoon

Procedual Wall Generation

I was doing some coding for my game recently, and I was wondering how you would going about doing procedural walls like shown in Software Inc. Currently, I have a system where you place a point in the world, that point is added to a list, walls are drawn between the points, and if the tiles (stationed between the world points) have the corresponding flag to them (!upwards, !downwards, !diagonal) then you may place the points. I was wondering 3 things.

  1. How would I go about upgrading this system to include diagonal walls

  2. How do I check if one wall runs into the other wall

  3. How would I go about finding the area between the walls and trigger the corresponding indoors flags?

Thank you for your time

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by jaspercayne · May 03, 2016 at 09:37 AM

  1. I would be storing the start and end coords of each wall, then it isn't too big a deal to just find a mid point and draw your wall between the start and end, just follow the diagonal direction you want the wall placed in.

  2. By storing the walls start, end, and direction you just need to check if a wall's intended path would cross between start and end.

  3. Since you've been saving the walls coordinates, you are really just checking the coordinates of your game object are in the bounds of the corners drawn by the outer walls. Possibly consider making colliders on the walls that extend much further than the width of the wall. Then you would just have to check if the object is touching all respective colliders and you know you are inside. If you have roofs it's absolute gravy. Just raycast up the appropriate distance from floor to ceiling, and if you hit the roof, you're indoors.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image aimmmmmmmmm · May 04, 2016 at 12:45 AM 0
Share

Thanks for the help!

For some clarification, currently I have it set up so that the wall spawns between the two points, and scales to the length between the two points, and then looks at the first point and rotates 90 degrees. However I have no idea how to do the math to find the correct tile. Currently here is my code for finding the tile and deter$$anonymous$$ing if the Diagonal Wall Used flag is active:

 for (float i = 0; i < $$anonymous$$athf.Sqrt($$anonymous$$athf.Pow(Pos1.x-Pos2.x, 2)+$$anonymous$$athf.Pow(Pos1.z-Pos2.z, 2)); i+=0.05f) {
                 if(worldInit.World.GrabTile(new Vector3(i + Pos1.x, 0, i*((Pos1.z-Pos2.z)/(Pos1.x-Pos2.x)) + Pos1.z)).DiagnalWallUsed){
                     Result = false;
                 }
             }

For number 2 and 3 thank you for your assistance!

avatar image jaspercayne · May 04, 2016 at 01:37 AM 1
Share

You can use transform.position to get a vector3 of the position of the object in the scene, where x and z are the horizontal coordinates and y is the vertical. 0,0,0 is the center of the scene, 3 dimensionally.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Drunkard Walk Algorithm C# Question 0 Answers

How to apply A* algorithm in C#? 2 Answers

Disable Mac OSX 'Active Screen Corners' 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges