• 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 SuperMasterBlasterLaser · Nov 06, 2014 at 03:03 PM · axispathfindingastar

How to make AIPath (A*) work on 2D game ?

I have 2D scene which got wall sprites and two vehicle sprites. All of them has 2D colliders. I have GameObject with AstarPath component.

I have created Grid graph, rotated it to 90 degrees by X axis. I have ticked Use 2D Physics and collider type RAY. Then changed size of my grid to make it have larger area.

Then added AIPath and Seeker to my vehicles and made target to each of them.

When I start play mode, both vehicles starts to move each other. However, they also start rotating in Y axis, they must be rotating by Z axis to make them look like steering. What I did wrong?

Comment
Add comment · Show 6
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 ExtremePowers · Nov 06, 2014 at 03:55 PM 0
Share

Is it a top down game? and can't you just lock rotation:

 function LateUpdate() {
     transform.rotation = Quarternion.identity;
 }

or

 private var iniRot : Quaternion;
 
 function Start() {
     iniRot = transform.rotation;
 }
 
 function LateUpdate(){ 
     transform.rotation = iniRot;
 }


avatar image SuperMasterBlasterLaser · Nov 07, 2014 at 07:10 AM 0
Share

Yes my game is TOP-DOWN game. I have locked rotation as you asked, used both of them. Now they just don't move.

avatar image Redeemer86 · Nov 07, 2014 at 07:15 AM 0
Share

If you have rigidbody attached to the game objects there are check box options in the inspector to freeze rotation in whichever axis you desire.

Red

avatar image SuperMasterBlasterLaser · Nov 07, 2014 at 07:25 AM 0
Share

Yes I have Rigidbody2D attached to my vehicles, but I don't have any checkboxes in instpector except is$$anonymous$$inematic, FixedAngle.

avatar image Kiwasi · Nov 07, 2014 at 08:08 AM 0
Share

Are you talking about implementing A* or implementing arongranberg A* pathfinding project. The two are not the same thing, and will result in very different answers.

Please clarify this point.

Show more comments

1 Reply

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

Answer by Kiwasi · Nov 07, 2014 at 08:57 AM

For arongranbergs in 2D there are a couple of options

  • Wrap the vector inputs and outputs from the path finding engine in a class that lets you work with your dimensions

  • Switch your project to work in dimensions that are compatible with the project (ie camera looking down the y axis

  • Break open the code and switch the dimensions around. You may find someone who has already done this

  • Use a version of A* implemented specifically for 2D

  • Implement A* your self (This is not overly difficult for someone of intermediate scripting ability)

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

30 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

Related Questions

astar' AI falls down, doesn't follow the grid 2 Answers

How to find the shortest path? 1 Answer

A* pathfinding - how to put penalty below a character 0 Answers

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

Lost in Pathfinding 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges