Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 shubhank008 · Dec 19, 2014 at 11:17 PM · pathfindinggridturn-based

2D Grid Movement (turn based)

I trying to create a Turn Based Strategy behaviour where you move a gameObject from 1 tile of a grid to another tile near it

I have created the Grid using sprites as gameObjects but can't sort out the movement part, I can move tile to tile continuously with mouseClick or w,a,s,d but want to implement the "player can move only x tiles a turn" thing, found in many TBS games

My current setup is like this

alt text

Comment
Add comment · Show 3
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 NoseKills · Dec 20, 2014 at 01:05 AM 0
Share

Without seeing any of your code, i can just state the obvious. You must make a counter that counts down or up as you make a move and make a condition so that when that number reaches a certain value, you can't move anymore.

avatar image MrSoad · Dec 20, 2014 at 01:08 AM 0
Share

How do you move from one tile to another?

Can you put a count in relation to this tile to tile movement code that limits total movement(how many times this code is executed)?

avatar image shubhank008 · Dec 20, 2014 at 06:24 AM 0
Share

@$$anonymous$$rSoad and @Nose$$anonymous$$ills thanks for your comments but I actually solved it, I created this question almost 12 hours ago, which took 3-4 hours to get approved and by that time by hit and trials, I finally found a method. Added some points as a answer to what I did.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer Wiki

Answer by shubhank008 · Dec 20, 2014 at 06:35 AM

To anyone in same situation as me, here is how I solved both my problems.

  1. Added Colliders to my charGO and tileGO around it.

  2. Created triggerCollider on player to get the tileGO player is standing on, added some conditional statements.

  3. Using the above tileGO, used Physics2D.OverlapCircleAll (+-1 x/y tileGO) to get the Colliders from each direction of tileGO

  4. Using each Collider, got the GO of the tiles from all direction. Changed their sprite to a different colored sprite to "visualize" walkable path

  5. Used coroutine, lerp and basic method to detect mouse click on a tile and move player from tileGO to clickedTileGO

Again, this was for a prototype to test out if I can do what I have in mind, once all is done, I will start cleaning the code and workarounds I used, create proper sprites, animations, etc. but this should give you some insight on how you can do it

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
avatar image
0

Answer by Lancemaker_ · Jan 16, 2015 at 12:42 AM

a*pathfinding can solve that. i cant program it, but there are lots of tutorials online, its easyer on 2d i think.

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Question about tactics movement 0 Answers

Grid based movement collision detection 1 Answer

Best way to implement a grid system 1 Answer

Best approach to generating a grid for basic A* pathfinding 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