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 wackytman · Sep 08, 2013 at 11:13 AM · javascriptainavigation

ai navigation help

i am making a ai that will go to a 10 different objects but it keeps stopping at the second one the script is not finished but i programmed it to go to the first second and third but it wont go to the third one this is what i wrote.Note: target1 and objecttarget1 is the same just in different form

 #pragma strict
 
 var target1 : Transform;
 var target2 : Transform;
 var target3 : Transform;
 var target4 : Transform;
 var target5 : Transform;
 var target6 : Transform;
 var target7 : Transform;
 var target8 : Transform;
 var target9 : Transform;
 var target10  : Transform;
 private var NavComponent : NavMeshAgent;
 var monster : GameObject;
 var objecttarget1 : GameObject;
 var objecttarget2 : GameObject;
 var objecttarget3 : GameObject;
 var Target4 : GameObject;
 var Target5 : GameObject;
 var Target6 : GameObject;
 var Target7 : GameObject;
 var Target8 : GameObject;
 var Target9 : GameObject;
 var Target10  : GameObject;
 
 
 function Start () 
 {
     NavComponent=this.transform.GetComponent(NavMeshAgent);
     NavComponent.SetDestination(target1.position);
 }
 
 function Update () 
 {
     NavComponent.SetDestination(target2.position);
     
     if(objecttarget2.active == false)
     {
         NavComponent.SetDestination(target3.position);
     }
 
             
 }
 
 function OnTriggerEnter(other : Collider)
 {
     if(other.gameObject.tag == "myflag")
         {
             other.gameObject.SetActive(false);
         }
 }
Comment
Add comment · 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 bubzy · Sep 08, 2013 at 11:42 AM 0
Share

I would make my own objects with an index and then either follow them numerically or have a publically accessible variable that states the next target

waypoint1.target = 2;

waypoint2.target = 3;

waypoint3.target = 1;

or something similar.

however im not familiar with navmeshes so I cannot specifically help with this problem

avatar image ShadoX · Sep 09, 2013 at 11:29 AM 0
Share

I'm not sure if I'm stating the same as bubzy, but wouldn't it make more sense to have a list/array with the target Transforms rather than 10 individual lines of code? You could easily iterate over the list/array.

0 Replies

· Add your reply
  • Sort: 

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

17 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

Related Questions

Multiple Cars not working 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

How to make it two seconds for Time.time? 2 Answers

How to make a selection system? 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