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
1
Question by Arano · Sep 17, 2019 at 12:27 PM · bug-perhapsinfo

transform/vector lists & Vector3.Set issues

So i have problems using Vector3.Set, it does not seem to work when using any list.

what does work:

  • Vector3.Set

  • vectorlist[i] = vector

  • transformlist[i].position = vector

what does not work:

  • vectorlist[i].Set

  • transformlist[i].position.Set

reading on the web i find it should not work with .position as this should be a copy not a reference, but this is false, (afaik..) as u can use it as transform.position = vector (this should not work with copy's).. so why does .Set not work...? a list should not return a copy (as we can prove this by setting the vector directly using transformlist[i].position = vector) also if it does not work because of .position.. why does directly setting a list of vectors not work either ( vectorlist[i].set )? any suggestions? i really feel like i should report this as a bug but maybe someone has some suggestions or knows what i am doing wrong.

.Set ONLY works when using a vector3 NOT from a list.

below is some code, supporting this is a scene with an empty game object (StartObject) with 20 cubes as child. pressing S and F changes the positions of the cube while A and D does not
(actually.. D it sets them back to the last value of F (not doing anything with vectorlist[i].set))

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class TESTSET : MonoBehaviour
 {
     List<Vector3> vectorlist = new List<Vector3>();
     List<Transform> transformlist = new List<Transform>();
 
     public GameObject StartObject;
 
     Vector3 tempvect;
     // Start is called before the first frame update
     void Start()
     {
         foreach (Transform child in StartObject.transform)
         {
             transformlist.Add(child);
         }
         Debug.Log(transformlist.Count);
 
         for (int i = 0; i < 20; i++)
         {
             vectorlist.Add(new Vector3(0, 0, 0));
         }
 
     }
 
     // Update is called once per frame
     void Update()
     {
         //DOES NOT WORK
         if (Input.GetKeyDown(KeyCode.A))
         {
             for (int i = 0; i < 20; i++)
             {
                 transformlist[i].position.Set(Random.Range(0, 10), Random.Range(0, 10), Random.Range(0, 10));
             }
         }
 
         //DOES WORK
         if (Input.GetKeyDown(KeyCode.S))
         {
             for (int i = 0; i < 20; i++)
             {
                 tempvect.Set(Random.Range(0, 10), Random.Range(0, 10), Random.Range(0, 10));
                 transformlist[i].position = tempvect;
             }
         }
 
         //DOES NOT WORK
         if (Input.GetKeyDown(KeyCode.D))
         {
             for (int i = 0; i < 20; i++)
             {
                 vectorlist[i].Set(Random.Range(0, 10), Random.Range(0, 10), Random.Range(0, 10));
                 transformlist[i].position = vectorlist[i];
             }
         }
 
         //WORKS AGAIN
         if (Input.GetKeyDown(KeyCode.F))
         {
             for (int i = 0; i < 20; i++)
             {
                 tempvect.Set(Random.Range(0, 10), Random.Range(0, 10), Random.Range(0, 10));
                 vectorlist[i] = tempvect;
                 transformlist[i].position = vectorlist[i];
             }
         }
     }
 }
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

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

110 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycasting stops working randomly 2 Answers

WaitForTargetFPS 1 Answer

LOD Bounds not recalculating properly, too small regardless of scale. 2 Answers

NavAgent not following on rebuilt NavMesh 0 Answers

Monobehaviour resets variables after the initialization cycle 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