Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 IronStarInteractive · Jan 24, 2017 at 08:06 AM · arrayvector3arraysempty

Vector3 Array Empties Its Self Immediately After Being Initialized

I seem to have a problem with my array of Vector3s every time i run the program and print the array slots there all empty even if i print it on the next line I've looked at answers that say how to do it and they don't seem to work either,

here is the code

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Test : MonoBehaviour {
 
     Vector3[] vec3 = new Vector3[7];
 
     void Start () {
         
         // Initialize Array
         vec3[0] = new Vector3(0f,0.008f,0f);
         vec3[1] = new Vector3(0f,0.003f,0.007f);
         vec3[2] = new Vector3(0f,0.003f,0.007f);
         vec3[3] = new Vector3(0f,-0.006f,0.002f);
         vec3[4] = new Vector3(0f,0.004f,0.03f);
         vec3[5] = new Vector3(0f,0f,0.015f);
         vec3[6] = new Vector3(0f,0f,-0.01f);
 
         // Print Array
         print(vec3[0]);
         print(vec3[1]);
         print(vec3[2]);
         print(vec3[3]);
         print(vec3[4]);
         print(vec3[5]);
         print(vec3[6]);
     }
 }

all help is appreciated.

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

Answer by Peaj · Jan 24, 2017 at 09:24 AM

Your Array is not empty.

By default the output of a float gets rounded to 1decimal place. Try to output the values like this and you will see they are not empty (just very small):

 print(vec3[0].ToString("0.000"));

Comment
Add comment · Show 1 · 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 IronStarInteractive · Jan 25, 2017 at 07:34 AM 1
Share

Thank you so much i finally found out what the problem was it didn't have anything to do with array being empty after all, but because the print said that it was zero i thought it must have been the array.

once again Thanks ;D

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Im misunderstanding arrays. 1 Answer

Can't build a Vector3 array 2 Answers

Find gameobject furthest from player along z axis 0 Answers

Random an Array to push to another Array 0 Answers

Most Optimal way of computing Delaunay Triangulation given an Array of Vector3 points 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