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 Kergal · Jul 16, 2013 at 02:48 PM · spawnnavmeshnavmeshagentspawningspawning problems

Navmesh problem with SpawnSystem

Hello everyone , I hope this has not been asked before (I could not find it)

I have created a simple spawning system for a tower defense kind of game to learn more about coding and the navmesh system. As long as I have only one agent walking along the navmesh everything works just find - however as soon as I spawn a second or third one - the first one will continue to follow its path, but all others will remain at their spawn point.

private void SetWaypoint(){ // store distance to the next waypoint distanceToNextWaypoint = Vector3.Distance(curWaypoint.position,myHeightPointer.position);

         //    if distance between waypoint and myself is smaller than minDistanceToWaypoint set my target to the next waypoint
         if(distanceToNextWaypoint <= minDistanceToWaypoint){
             
             //    the path has a quadratic outline -> therefore do only increment the array number if I am not at the last waypoint already
             if(int.Parse(curWaypoint.name) < (gameManagerScript.allWaypoints.Length-1)){
             
                 curWaypoint = gameManagerScript.allWaypoints[(int.Parse(curWaypoint.name)+1)].transform;
             
             }
             //    start all over again
             else{
                 curWaypoint = gameManagerScript.allWaypoints[0].transform;
             }
         }
         
         //    if I am too far away - I have to get closer to the current waypoint
         else{
             
             nav.destination = curWaypoint.position;
             anim.SetFloat("Speed", 1f);
         }            
     }    

To further illustrate the case I have taken 2 screenshots . the first screenshot shows the totally confused AI-agents. Waypoints are all marked with their names ( 1-3 in red) + spawn waypoint (0 in green) , the actual navmesh in blue. The selected agent is the "working" first agent.

The second screenshot shows the components of the AI-agent.

[IMG]http://i40.tinypic.com/msfvrs.png[/IMG]

[IMG]http://i42.tinypic.com/x5v49j.png[/IMG]

It would be great if you could help me and tell me what I am -obviously - doing wrong. I know that I do not really need the navmesh system in this instance, but I would like to learn how to use it and furthermore if I somehow have to move the AI anyways. Thank you for your help. I hope I have given enough information.

BTW: I would have a second question. Is it possible to create a path with the navmesh so that (taking the example scene I have provided in screenshot 1) the agent will walk from waypoint 0 to waypoint 0 with the condition of passing through waypoints 1,2,3 ? The result is the same - but I would have the entire path. and could then have the cannonball tower aim a little ahead of the AI. Is that possible ? Or would anyone know a work-around for this problem ? Thank you for your help. :)

Best wishes,

Kergal

EDIT:

I have changed the allwaypoints from index 0 to index 1 in the start function - result . First agent still works, second agent works! until the first agent reaches the first waypoint . As soon as the first agent changes his waypoint (nav.destination) to waypoint 2 - the second agent will do the same thing. however the third agent will have waypoint 1 as its destination and will the just stop at waypoint one.

Comment
Add comment · Show 1
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 Kergal · Jul 19, 2013 at 05:32 AM 0
Share

bump.

no one here ? question to stupid?

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

16 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

Related Questions

[Help] How Do I Randomly Spawn Game Objects On Specific Coordinates? 3 Answers

How to make enemies spawn IN the ground without rising up automatically first? 1 Answer

Navmesh After Spawn 2 Answers

Instantiating Enemy AI NavMesh Agent SetDestination Error 1 Answer

Spawning help 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