• 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
Question by Arno 2 · Jun 13, 2010 at 07:28 PM · pathfindingtargetwaypointastarnext

A* pathfinder - next target

I'am using Arons A* pathfinding.

I want a character to move from one point to another. I'am just starting with unity and these are my first scripts.

The script doesn't give any errors, but it doesn't work.

What is wrong?

var target : Transform[]; var timer : float = 0.0; var Rate : float = 1.0; private var currentTarget: int;

function FixedUpdate () { timer += Time.deltaTime; if(timer > Rate){ this.GetComponent("Seeker").StartPath(transform.position,target[currentTarget].position); timer = 0; } if(Vector3.Distance(transform.position,target[currentTarget].position)<=0){ currentTarget++; if(currentTarget>=target.Length){ currentttarget = 0; } } }

Comment
Tzan

People who like this

1 Show 2
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 spinaljack · Jun 13, 2010 at 09:26 PM 2
Share

Why don't you e-mail Aron?

avatar image Cyclops · Jun 27, 2010 at 06:40 PM 0
Share

@Arno, remember to checkmark the Answer, if it helped you, thanks.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Tzan · Jun 13, 2010 at 11:30 PM

currentttarget = 0; <---- You have 3 lower case "T"s here

currentTarget = 0; <--- should look like this

The answer:

Rather than check the remaining distance is <=0, maybe try <=.1 The distance returned is probably not negative, and might never really equal 0, so just check if its close.

Comment
Cyclops
Peter G
Takuan Daikon
TowerOfBricks

People who like this

4 Show 6 · 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 Arno · Jun 14, 2010 at 06:31 AM 0
Share

Tzan thank you for the comment i didn't see that one.

problem however still remains. The script doesn;t go to the next target(/waypoint) it doesn't update

avatar image Tzan · Jun 14, 2010 at 05:09 PM 0
Share

Does it walk to the first waypoint at index [0] if you position the character away from it?

var Rate should be var rate, lower case "r"

avatar image Tzan · Jun 14, 2010 at 05:16 PM 1
Share

I havent used the pathfinding script so if you are using it wrong I cant help.

Rather than check the remaining distance is <=0, maybe try <=.1 The distance returned is probably not negative, and might never really equal 0, so just check if its close.

avatar image Arno · Jun 15, 2010 at 06:07 AM 0
Share

THANKS...it works now. The distance was the problem. Tank you for answering...

avatar image Tzan · Jun 15, 2010 at 04:22 PM 0
Share

Great! dont forget to mark this question answered. I edited the answer.

Show more comments

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Sidescroller AI/Pathfinding/Flags/Waypoints 0 Answers

Clone not following Target 1 Answer

Help with a simple AI 2 Answers

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

Pathfinding over a dynamically deforming mesh 0 Answers


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