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 Neshert · Apr 10, 2018 at 11:18 PM · movementgrid based gamecombined mesh

Click to move in a 3d-blockbased single mesh

Hello there, this is going to be my first question although I've been reading Unity answers for a while now.

I'm trying to make a 3d game with block-based terrain just for learning purposes. I've read a lot about optimizing the terrain combining groups of cubes/blocks into one single mesh. I've made a script to combine each cube/block mesh into one single mesh like here:

alt text


I'm using a simple script to move the player (capsule) 1 unit when left, right, up or down is pressed and it's working perfectly fine for my goal.

The thing is, since that terrain is now a single mesh, I don't know if it's possible to handle each cube/block on its own so that I can click on one of them and move until there with grid-based movement like I'm doing with left, right, up and down buttons.


To sum up, I want to move with a grid-based movement system to the block I've clicked inside the single mesh. I'll explain it below.


My first question is how to move to the yellow block?. I think it's more or less easy since maybe I can calculate the difference in X and use Move.Towards() with fixed units i.e 3 units in this case.

But, my second question is, what if there are obstacles in between? I want to move to the green block. I have to use some pathfinding algorithm but.. how? Since there is only a single mesh, how can I calculate the best path to a block if I don't have the block coords stored anywhere? I don't know that the purple obstacles are there and that I have to avoid them. How can I do it? alt text


Thanks so much in advance!

captura1.jpg (51.4 kB)
captura1-copia-2.jpg (87.0 kB)
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
0

Answer by oroora6_unity · Apr 10, 2018 at 11:36 PM

Pathfinding isn't something easy, all the tips i can give you for now is to look into Graphs (which is how our very much loved lists works!) You can learn about graph theory here and then apply it maybe with an array of nodes collegated by edges by giving each node a variable containing a position. once you've done that try going for a map generation, so after the graph is ready build a map according to it. If you reach that point you should move towards creating a pawn to move in your game through a Dijkstra algorithm and only then once you have complete knowledge about what pathfinding is, you should move towards optimization by making the static blocks turn into one singular mesh and moving towards an A* pathfinding algorithm which is more efficent, but harder to apply. I remember doing something like this in the past, if you put your soul into learning this, you should be fine and make your first pathfinding strategic game!

Comment
Add comment · Show 1 · 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 Neshert · Apr 11, 2018 at 09:01 AM 0
Share

Thanks for the answer @oroora6_unity ! So, if I've understood it properly, what I really need is to store the blocks/cubes/tiles position in some kind of array or whatever so I can instantiate the map from there and then use a pathfinding algorithm since I know each "pathable" position? But what If I want to do the map manually? I mean, I want to create the map block by block and then merge them into one single mesh? I still need to store the position data somewhere before merging? Is it really necessary to have the position stored to achieve this?

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

117 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

store the user touch input 0 Answers

How to detect what tile player is standing on in a tile-based game 2 Answers

3D Grid Based Movement (X-Com 2012 etc) – How to implement vertical movement? 0 Answers

2D Isometric grid movement direction 0 Answers

Save a precalculated grid path into a jagged 2d array ready to be loaded when need 0 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