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 /
This question was closed Feb 14, 2018 at 10:07 PM by tetramess for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by tetramess · Feb 14, 2018 at 04:15 PM · pathfindinggridhighlight

Pathfinding movable area on a grid with varying movement costs

In my 2D grid turn based project, during his turn a player moves from tile to tile, and for each tile of a certain type that he walks onto, I deduct a certain amount of 'move points' from his 'turn move power'.

I want to highlight the area in which the selected character can move during the current turn. Problem is, everything I was able to find only explains different ways on how to calculate the shortest path between Points A and B.

My question is: is there no other way to accomplish this, other than to check every single tile of my map (or those in the vicinity), and highlight the ones to which the cheapest path costs less than the player currently has 'move power left', or is there some more popular/effective way to do this? My concern is, that if a player's 'turn move power' reaches higher numbers, I will be making my game calculate a hundred shortest path algorythms. Any ideas on how should I go about making the highlighting happen would also be appreciated. Thanks!

Right now the best candidate looks to be Dijkstra's algorythm, since my tiles would have a 'weight', but is that really the way to go?

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

  • Sort: 
avatar image
0
Best Answer

Answer by · Feb 14, 2018 at 06:39 PM

@tetramess Depends on how you impemented your "terrain" and how you want movement to work, for example: is diagonal walking enabled or not? Let's say its a 2D grid of cubes. when considered diagonal movement, calculating your range of movement is extremally simple: its a square with side of (2*x)+1 cubes, where x is character range. But since you will (probably) implement movement from point A to B selected, you will have to use pathfinding algorithm anyway. There are A LOT of youtube tutorials, mostly with hex grid, which is even more complicated. Worry not about calculations :) you will be working on simple arrays using A* or Dijkstra, using pathfinding only when needed. As for highlighting desirable range of movement, my first thought was creating a circle/sphere collider around your character and highlighting tiles that are inside, but still using an algorithm on simple array could be faster, but probably unnoticeably. As for sample project you can check [this very old project][1] its well written and works even in unity 2017.3 but i still recommend you starting with some youtube tutorial. Happy coding! [1]: https://github.com/hakimio/KR/tree/master/Project/Assets/Scripts/Arena
Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

79 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

Related Questions

Find a path with specific steps (moves) on a grid 0 Answers

PATHFINDING in a grid game 2 Answers

Grid-based path-finding, similar to Legend of Grimrock/Eye of the Beholder... 2 Answers

ai pathfinding project getting started scene problems 1 Answer

Accessing a nested list of gameobjects not working quite right 1 Answer


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