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 alimolavi · Sep 20, 2011 at 08:44 AM · ai

A* Simple AI help !

Hi everyone i work on a game , on this a lot of people walk from waypoint to waypoint randomly , but some time this people Collision together that is sound too bad , how can i fix it !?

Comment
Add comment · Show 5
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 CHPedersen · Sep 20, 2011 at 09:52 AM 5
Share

Your question makes very little sense and seriously lacks more elaborate explanation.

avatar image MatthewAtMcK · Sep 20, 2011 at 10:25 AM 1
Share

Not that I can help with your problem really, but I think I understand the question. He has characters walking from one point to another choosing a random path and because there is no path finding as such, there is no way to detect if they will collide so they just walk through each other/into each other sometimes. What he wants to do is (I'm guessing from the title) use an A* path finding algorithm so that if a character were to be on a path to collide with another character, it would realise and change it's path.

I've not used an A* path finding algorithm myself but have seen examples and would to see how you do it if you work it out. One problem I see with this though is that A* path finding, whilst a fairly efficient way of finding a path for one object around a static map, I imagine would struggle seriously if you had "a lot of people" walking around. Because then, each character would have to recalculate it's path each frame to be certain of no collisions. You could only do it every few frames, but you may get collisions, or you could have a larger collider than the character so that it would only recalculate paths when a collision occurs.

Have you done any research into A* path finding algorithms yet? That would definitely be my recommendation of where to start (http://www.policyalmanac.org/games/aStarTutorial.htm). Which scripting language are you using? It would be very helpful if you edited you original question to include more information on what you want to do and in which language, what background you have, what research you have done and what functionality you already have in place in your project.

$$anonymous$$att

avatar image Owen-Reynolds · Sep 20, 2011 at 03:38 PM 0
Share

A common solution is to do a quick raycast -- maybe look 8 feet ahead of each walker, twice a second. If you see another walker, scoot sideways. If you want to get fancy, check if the other guy is to your left or right and which way they are moving, and scoot the best way (a lot more work, but short once you get it and looks really nice.)

But, yeah, confusing Q. Why is A* in the title?

avatar image testure · Sep 20, 2011 at 04:24 PM 2
Share

I always find it a little sad when more effort is put into helping somebody than the original poster put in to asking the question.. :\

avatar image timberlandboots · Sep 21, 2011 at 11:53 AM 0
Share

====( http://www.clothes6.us )=====

online store wholesale sneakers,Jerseys, jewelry, glasses, shirt, sports,handbags,clothes ,news, vogue,jeryse at ugg boots,luxury fashion ysl women boots, christian louboutin boots,ed hardy clothes, jordan shoes,nike shoes,hoodies,t-shirts,nfl jerseys,mlb jerseys,nhl jerseys,coach handbags,handbags,wholesale, retail, sunglasses,belts, caps, ed hardy caps,suit,fashion good,newest style goods All the products are free shipping,

====( http://www.clothes6.us )=====

free shipping

competitive price

any size available

accept the paypal

jordan shoes $32

nike shox $32

$$anonymous$$BT shoes 48

NFL jersys 24

NBA jersys 24

Timberland boots 45

Christan Audigier bikini $20

Ed Hardy Bikini $23

Smful short_t-shirt_woman $14

ed hardy short_tank_woman $15

Sandal $26

christian louboutin $60

Sunglass $14

COACH_Necklace $18

handbag $33

AF tank woman $16

====( http://www.clothes6.us )=====

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bovine · Sep 21, 2011 at 11:25 AM

I am using A* in our RPG which is tile based. Players and enemies have two gameobjects with box colliders attached. One for the current and another I use to reserve the next tile while the controller moves the player or enemy from tile to tile. When not moving this 2nd collider is hidden.

My A* implementation raycasts tile centre to tile centre at head height above the tile's floor and therefore sees these box colliders as impassible. Granted this does mean that the paths fail where two enemies walk in opposing directions but it is sufficient for m purposes and seems to scale well enough so far.

You could of course, upon collision with these box colliders during pathing attempt to negotiate with the owning enemy and naturally there may actually be a path by the time the enemy gets there, but it's reasonable to just repath later, if potentially computationally more expensive.

Hope that helps Ian H

Comment
Add comment · Show 4 · 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 Bovine · Sep 21, 2011 at 11:29 AM 0
Share

Obviously I'd you find your entities would collide moving from tile to tile, you can halt following the path and repath from there, presu$$anonymous$$g your blockage will go eventually.

You might want to consider using behavior trees to make some of the decisions about where to path to and what waypoints to pick. Check out AngryAnt's free unity implementation at www.AngryAnt.com. And follow his links to read and watch videos about BTs on www.aigamedev.com

avatar image Owen-Reynolds · Sep 21, 2011 at 01:05 PM 0
Share

Generally tile-based path-finding is done entirely through your 2D array. Ins$$anonymous$$d of using a collider to claim a "move to" space, mark it as used in the array. Ins$$anonymous$$d of raycasting to check whether a path is open, use math to directly check the used variable of the squares you will move through.

avatar image Bovine · Sep 21, 2011 at 08:38 PM 0
Share

@Owen Reynolds we did not use an array because our movement is tile based but our world is fully 3D so we would really need a 3D array. Players and Enemies can walk along each level but that level is not necessarily flat and indeed there could be levels above or below where the player/enemy currently stands that are largely freeform.

You could however avoid the raycasting and tile reservation colliders if you used Owen's suggested approach for a tile based game. If however your world is 3D you could still consider my tile reservation approach, but consider that your are reserving a node.

Efficient use of layers reduces the cost of raycasting and tile reservation.

avatar image Bovine · Sep 23, 2011 at 08:43 AM 0
Share

It's worth noting that as @Owen Reynolds says, with a grid raycasting can be avoided. We are considering restructuring our level collision models so that we can precompute a grid for a given level. This is not trivially, but I think I have a way. For a tile based implementation, I can then precompute things like tile heights, whether a tile is open or closed, whether it is possible to pass from one tile to the next, all things I am currently computing on the fly. Naturally this also means that logic needs updating for when doors and barriers are opened/closed to make changes to the relevant map tile, or perhaps the edge. We'll then need a way for the player (or enemy) to pass from one grid to another without issue.

So if I do all of the above, there's some work to do in the editor to create these maps and some work to do allowing player's and enemies to transition from map to map and we know longer need a 3D array, more we accept that players are bound to a tile and nothing can pass above or below them unless it does so within a separate map, which would only be an issue for flying creatures, so unlikely to be an issue at all in this first pass.

This fairly considerable amount of setup means that path finding and movement will be more efficient and indeed, I wouldn't even need the player or enemies to move via a CharacterController.

It looks like there may be a masterclass on collision avoidance (which was the original topic) on aigamedev.com but you'll need a premium account to view it. I would check but I have issue logging in sometimes...

http://aigamedev.com/premium/event/session-collision-avoidance/

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

6 People are following this question.

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

Related Questions

Ai Upgrade?? Possible 1 Answer

Restricting NavMesh path finding directions 1 Answer

Multiple navMeshes? (swapping navMeshs at runtime) 0 Answers

Ai keeps walking in a circle. 2 Answers

Enemy Color Change Help! 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