• 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 /
  • Help Room /
avatar image
0
Question by GKuhns · Mar 28, 2017 at 07:11 PM · prefabswaypoint

Is there a solution for the waypoint prefab issue?

I have a prefab of an enemy AI car, and a script which will instantiate this prefab at set intervals. I want to have the instantiated prefab follow a waypoint course, to strafe our base. The problem is that when I make a prefab out of the enemy car, it loses the waypoint circuit assigned to it. I tried re-assigning the waypoint circuit to the prefab, but Unity won't let me do that. I tried making a prefab out of the waypoint circuit. Unity will allow me to assign that prefab (of the waypoint circuit) to the prefab of the enemy car, but when instantiate that prefab I get the error message:

"IndexOutOfRangeException: Array index is out of range. UnityStandardAssets.Utility.WaypointCircuit.GetRoutePosition (Single dist) (at Assets/Standard Assets/Utility/WaypointCircuit.cs:66)"

I'm hoping that there is a way to use code to assign the original waypoint circuit to the circuit variable of the WaypointProgressTracker.cs (the script attached to the car, where you drag & drop the desired waypoint circuit.)

The real problem is that I am not (yet) much of a coder - still working my way through the beginner set of tutorials... I'm just unsure what my approach to this problem should be - I tried making an alternate version of the WaypointProgressTracker.cs script, to allow me to assign the waypoint circuit on Start, but that effort failed every which way, again, because at this point, I'm still in waaay over my head. :)

If anybody can share a working solution for this issue, I would be most grateful. At this point, the work-around is pretty ugly - have a bazillion copies of the enemy car in scene, but set inactive, and a script to activate them... works, but I'd really prefer to have the cleaner approach of instantiating a prefab.

Thanks for any help!

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 hexagonius · Mar 28, 2017 at 10:12 PM 0
Share

you usually need to do three things:
- instantiate your car.
- Get the WaypointProgressTracker script from the instance.
- assign the waypoints to it

this should be done in a $$anonymous$$onoBehaviour that's part of the scene and knows the waypoints

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GKuhns · Mar 29, 2017 at 04:24 AM

Well, I have step one and (sort of) two - I can instantiate my car, and I can make a variable for a public Behaviour, and assign the WaypointProgressTracker script to it in the inspector... What I can't find a way to do is the last step - assigning the desired waypoint circuit. As I mentioned, I tried making an alternate version of the WaypointProgressTracker.cs script, to allow me to assign the waypoint circuit, but because I really don't know my way around coding yet, I can't figure out exactly how to do that last step....

Any ideas?

Comment
Add comment · 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
0

Answer by Zykroma · May 29, 2017 at 07:00 PM

Hello ! I was having the same problem and I figured out what was going on. There is 2 Waypoint Circuit scripts. You need to use the one that do not propose to change the color and you need to drag the script into the inspector. Not the gameObject.

Comment
Add comment · 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

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

99 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

Related Questions

Finding waypoint from prefabs and make them high priority than the exiting waypoint from the scene 0 Answers

Making a prefab travel from waypoint to waypoint on terrain 3 Answers

Deleting a gameobject/prefab that has been instantiated 0 Answers

Unity is not recognising MonoBehaviour,Unity not recognising MonoBehaviour 0 Answers

AI Waypoint rotate problem 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