Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 alfaro190 · Jul 05, 2015 at 04:48 AM · vector3linerendereroutofbounds

Index Out of Bounds Line Render

So i get an error on path.SetPosition (i, newPos); saying index is out of bounds? I am not sure why or how to solve this. the variable newPos is a vector 3 updated as the game object follows pose. I know its working because instantiate an object when The gameobject pose is moving. I can also print the current vector 3 of the Newpos. so why the error? I just want to build a line render as the object moves to then carry that over to the next scene, but cant get pass this error

Thanks for the help in advance.

     private Vector3 lastPos;
     private Vector3 newPos;
     private bool isMove;
     private int i;
     private LineRenderer path;
 
     public GameObject wayPoint;
     public GameObject pose;
 
     void Start ()
     {
         i = 0;
         path = GetComponent<LineRenderer> ();
         StartCoroutine (trackMove ());
     }
 
     IEnumerator trackMove()
     {
 
 
             lastPos = pose.transform.position;
             yield return new WaitForSeconds (0.5f);
             newPos = pose.transform.position;
             
 
             if (lastPos != newPos) {
                 Debug.Log ("Im moving");
                 path.SetVertexCount (i);
                 path.SetPosition (i, newPos);
                 i++;
             } 
             else if (lastPos == newPos) {
                 Debug.Log ("not moving);
                            isMove = false;
             }
             StartCoroutine (trackMove ());
     }

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
0
Best Answer

Answer by alfaro190 · Jul 07, 2015 at 05:49 PM

Figure it out. I couldnt have the vertex count and path position both equal to the same variable. Since the variable of vertex counts starts at 0 and the path position starts at 1. So I when it was updating it kept creating one more vertex that there was a position. to fix it I could either set vertex to one, but instead I created another int var and set that equal to 1.

So the path position is equal to one and the vertex count is equal to 0;

problem was solved

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.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Vertices Array only given in local coords? 1 Answer

Laser Render Reflect Angle incorrect 1 Answer

Making a ball move according to swipe of the mouse 0 Answers

how to find a point(vector2) between two points(Vector2) of a line (line renderer) 2 Answers

Need to find a point in a line using a percentage and a Vector3 list. 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