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 /
  • Help Room /
avatar image
0
Question by siddharth3322 · Dec 12, 2015 at 05:16 PM · movementenemypathunity 4.6enemy ai

Move enemy only touching border

I want one of my enemy moves only at borders of surrounded area. My enemy must touch any side of border and continuously move around its limit. Surrounded area is completely dynamic as per main player take its movement.

Following image give you more idea regarding this. I have to move on dotted path and path is dynamic. I need some suggestion about this type of implementation.

alt text

img-20151212-222515.jpg (386.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
1

Answer by dhore · Dec 13, 2015 at 02:45 AM

I'm not sure how familiar you are with AI pathfinding techniques ...but you could make a script that will generate a series of path nodes (depending on how your walls are generated you could use them to generate nodes in front of them?) and then just use an algorithm like A* to path around the nodes to the desired locations.

Comment
Add comment · Show 11 · 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 siddharth3322 · Dec 13, 2015 at 03:28 PM 0
Share

Thanks @dhore, for your response. $$anonymous$$y area get filled based on grid. So as cells are get filled by player movement as new path is generated for enemy.

So how to detect enemy path in this kind of situation?

avatar image dhore siddharth3322 · Dec 14, 2015 at 12:06 AM 0
Share

Well you'd have a Node $$anonymous$$anager class which would keep track of all the pathing nodes - and the pathing nodes themselves would have data like their neighbouring nodes that you can traverse to (used for A* implementation). Then as your map/grid updates and changes it will need to be updating/generating new paths and adding new nodes to the manager class and possibly deleting nodes if you close sections too. Then as long as your enemy doesn't get cut off in any way on the grid he should still be able to use A* pathfinding like normal, it would just be on a constantly changing and evolving node grid.

avatar image siddharth3322 dhore · Dec 17, 2015 at 09:28 AM 0
Share

$$anonymous$$y plane is completely divided in grids. As player moves filling those grid cells. So how to detect corner cells to draw path for edge monster (enemy)?

Show more comments
avatar image siddharth3322 · Dec 17, 2015 at 09:49 AM 0
Share

Thanks @dhore, now I have to implement this. Then after get back to you. Do you have any way through which I can travel node to node? Right now in my code, enemy take small pause at every node, not moving smoothly to node per node.

I hope you understand my this question. If you have any better way to solve this then please suggest me :)

avatar image dhore siddharth3322 · Dec 17, 2015 at 10:16 AM 0
Share

As I mentioned in my original answer, I'd suggest using A*. If you don't know what A* is (pronounced "A star"), it's one of the most optimized pathfinding algorithms that is very commonly used for game AI pathfinding. If I had a link to a good tutorial then I'd definitely give it to you, but unfortunately I don't since I learnt it at Uni .... so I guess you're going to have to google for a tutorial yourself...

So from what I understand you are already using some sort of algorithm for the AI to calculate which node they should go to next to be able to get closer to the player. What A* does is when you give it a node to go to it'll calculate a list of nodes that you need to traverse (in order) to get to the destination node, and then you just loop through the list until you get there.

avatar image siddharth3322 dhore · Dec 17, 2015 at 10:50 AM 0
Share

Here in my case, I don't need A* because I don't want to select a path. I just need to traverse around available nodes. I don't want to catch enemy but I just want to move enemy by touching border.

$$anonymous$$y available node list is continuously updated based on your above suggestion. Now I just want smooth code to travel node to node.

Show more comments
avatar image siddharth3322 · Dec 17, 2015 at 11:20 AM 0
Share

Yes, you are on the same path. but how to do this?

avatar image dhore siddharth3322 · Dec 17, 2015 at 11:26 AM 0
Share

Sorry, but I can't really give you any code to help as I don't know the structure of your pathing system. But pretty much just while the AI is moving from one node to the next, start calculating where they should go if they were at the destination node already, therefore when they get there they already know the next move.

avatar image siddharth3322 dhore · Dec 17, 2015 at 11:36 AM 0
Share

Okay thanks for your help. Now let me implement this after that I will get back to you.

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

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

How to make enemy detect a character in his certain range? 1 Answer

How do I get my enemy to flip to face the direction he is moving? 3 Answers

Enemy direction going crazy after collision 1 Answer

my enemy recognizes one instance of the player entering a box collider in order to apply damage but not to trigger it to chase the player 1 Answer

How to have multiple enemies (currently having to kill them in order) 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