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 Kotie · Oct 27, 2018 at 12:07 AM · movementpathfinding

AI movement with other factors such as paths that increase walking speed

I've been thinking about finally approaching AI within my projects as it limits me not being able to do much without so (plus knowing AI would make my university life easier within my degree)

Right now I am gonna start off simple with movement.


Context: An NPC has a certain path desired (such as a saved point based on mouseclick on screen). Ideally, the NPC would walk straight over to the point and find the shortest path. Sounds simple. Now, what if instead of walking the shortest distance, there is a path which increases movement when walking on it. Overall, the travel time would be shorter due to the longer path having a higher movement speed.


Question: How would I go about choosing the right path based on shortest travel time? Context should give an example. I know A* would be able to find the shortest path, but I am unsure what my options are if I were to change movement speed on a certain part of my level.


Keep in mind I am NOT asking for code but for how to go about this as I would love to learn this and not just copy/pasta. I know Google might have the answer but I am simply just bad at figuring out what to Google.


Thank you, everyone :)

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 Jordash · Oct 27, 2018 at 01:36 AM

I'm gathering you are implementing the path finding yourself from scratch, so I won't talk about the built in path finding. Fundamentally the A* algorithm allows you to weight paths, so an area that is traversed faster by your agents can be weighted in such a way it appears to be shorter than a slower path of equal length.


There are many ways to implement a A* as well as how you define these faster areas for an agent to understand, so I won't get too much into that, but this is a great resource for path finding: Red Blob Games. which should get you started on the right track. Most implementations are valid, it all comes down to the type of game you are making and what is most appropriate.

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 Kotie · Oct 27, 2018 at 12:10 PM 0
Share

I will for sure have a look at the post you sent :) I am wondering how different it is in C# as I've noticed the blog uses Python to explain the code

avatar image Jordash Kotie · Oct 27, 2018 at 12:34 PM 1
Share

There are some c# snippets here but I don't think it goes all the way to A* like the python code does. The best part of Red Blob is the explanations though, once you understand the concept it should be much easier to develop your own code.

avatar image toddisarockstar · Oct 28, 2018 at 03:50 AM 1
Share

try a simple a* star algo first. i would recommend googling a simple drawn out explaination of how it works(without code) so you can wrap your brain around the concept before you start coding.

try coding it without the added preferences between the nodes first. you can always add the preferences between nodes to your node class afterwords. to set up a* in a grid pattern you can use an array of arrays in c#. probly of your custom node class to hold your info. then you can move through your x and y coordinates like this: myarrayofarrays[x][y] = whatever.

if you are not wanting to use a regular grid you can also use an array containing lists of connections to the other indexes in the array and move through your search pattern that way.

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

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

Related Questions

2D Isometric Movement Path (8 Directions) 2 Answers

Characters contending for same position 1 Answer

pathfinding with instant movement(no turning) 0 Answers

Non-player movement 1 Answer

Making a bubble level (not a game but work tool) 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