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 sacredgeometry · Jun 02, 2013 at 09:26 PM · aipathfindingnpc

NPC Fleeing with Unity Pathfinding?

What is the best way to make enemies flee from your character. I need to create almost an impulse where the player causes the enemies to run away from him in all directions. I have tried a few things, one of which was additivly altering their destination but this didnt really have the effect i wanted.

Any tips, maths or links to information is appreciated.

Kind Regards

Brian

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
Best Answer

Answer by Owen-Reynolds · Jun 02, 2013 at 09:41 PM

Pathfinding and fleeing in terror usually don't mix. Fleeing might be running down a hallway and turning into a dead-end. Even if you know about the dead-end, still an OK place to hide (and you might forget in your panic.) Pathfinding will never have you run into a dead-end.

With pathfinding, you first pick a spot. Suppose you pick just past the end of the hallway. The pathfinder figures out you have to run crosswise to the scary thing in order to get to there. It ends up looking more like "everyone and calmly follow the exit signs" Using pathfinding + avoidance will probably prevent you from "fleeing" towards an enemy standing in the only doorway out of a room, but it can't help you know what to do in that situation, or where to try to flee to in the first place.

Simplest trick is to do a few quick ray casts "away" from the scary thing, and run whichever one has the most room.

Comment
Add comment · Show 3 · 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 sacredgeometry · Jun 02, 2013 at 09:50 PM 0
Share

That is probably a little more sophisticated than I need and probably a little expensive considering all I really need is for the NPC to run in the opposite direction to the player. You did give me a clue though.

I think I may have to bust out some pythagoras theory. Work out the direction vector and just get them to run along it if a forward facing ray doesnt have a collision too close otherwise pick another direction to run in.

It just feels a little clunky to be honest. There must be a standard fleeing algorithm out there.

avatar image Owen-Reynolds · Jun 03, 2013 at 02:33 AM 0
Share

The run direction is just me.position - scrayThing.position;. Same as chasing someone, but negative.

There isn't really a standard way that things should flee, which means there's no standard flee code.

avatar image sacredgeometry · Jun 03, 2013 at 05:42 PM 0
Share

Its ok I sorted it but as you gave me the idea, heres one internet :) Have a nice day.

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

15 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

Related Questions

Sidescroller NPC follows Player 0 Answers

How to use A* pathfinding for a large map? 2 Answers

A* or AStar Pathfinding doesnt work for me? 0 Answers

Follow up to AI Pathfinding Question 0 Answers

How to forbid an NPC to move diagonally using Character Controller? 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