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 Sgt_Spike · Jul 03, 2018 at 04:55 PM · positionvector3

Vector3 does not work

Hey, can someone help me understand what the problem is here with my vector3. I'm using a vector3 to change the position of a gameobject. In an update loop, I have the code 'boss.transform.position = new Vector3(8.406086f, boss.transform.position.y, -12.64066f);'. Y is not set to a value because this can change, however, the x and z values stay the same all the time. I would think by using this line of code the x axis of this object will always stay at '8.406086' and the z axis will always stay at '-12.64066', but it doesn't. For some reason the objects go to the coordinates of x = 18.25217 and z = -23.80132. If someone could tell me where I'm going wrong that would be great because I am super confused right now and have been looking at this for hours...

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 mauriciomb · Jul 03, 2018 at 05:02 PM

can you post your code? Also, is your object a child or parent of another object?

Comment
Add comment · Show 5 · 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 Sgt_Spike · Jul 03, 2018 at 05:34 PM 0
Share

Thanks for the quick reply. Bit of an issue, my code is too long to post. :D It's 500 lines long. There isn't actually much to see here. The only time I ever use the 'boss' variable here is in that one line of code I posted before.

alt text

Also here is the structure of my hierarchy. The first 'Chapter1Boss' is the 'boss' gameobject in my code, so it's basically a child and parent object. Does this matter then? The 'Level10Intro' object also has an animation attached marked as Legacy where the y coordinate of 'boss' changes. I don't think that will affect it though.

Edit: Also before you ask, I definitly have referenced the right 'Chapter1Boss' in the script :D.

tests.png (7.6 kB)
avatar image mauriciomb Sgt_Spike · Jul 03, 2018 at 05:38 PM 0
Share

make sure that the child "Chapter1Boss" object position is set to (0,0,0) in the inspector.

avatar image Sgt_Spike mauriciomb · Jul 03, 2018 at 05:55 PM 0
Share

That doesn't work sadly. The position of it was already (0,0,0) to begin with.

Show more comments
avatar image Sgt_Spike · Jul 03, 2018 at 05:36 PM 0
Share
 void Update ()
     {
         boss.transform.position = new Vector3(8.406086f, boss.transform.position.y, -12.64066f);
 
         if (chapterNumberText != null)
         {
             chapterNumberText.text = chapterNumber.ToString();
         }
         if (levelNumberText != null)
         {
             levelNumberText.text = levelNumber.ToString();
         }
 
         if (endTheLevel == true && hasStartedAnimations == false)
         {
             StartCoroutine(StartAnimations());
             hasStartedAnimations = true;
         }
         if (endTheLevel == true)
         {
             currentNode = null;
         }
 
         if (button1State == true)
         {
             button1On.SetActive(true);
             button1Off.SetActive(false);
         } else
         {
             button1On.SetActive(false);
             button1Off.SetActive(true);
         }
         if (button2State == true)
         {
             button2On.SetActive(true);
             button2Off.SetActive(false);
         }
         else
         {
             button2On.SetActive(false);
             button2Off.SetActive(true);
         }
         if (button3State == true)
         {
             button3On.SetActive(true);
             button3Off.SetActive(false);
         }
         else
         {
             button3On.SetActive(false);
             button3Off.SetActive(true);
         }
         if (button4State == true)
         {
             button4On.SetActive(true);
             button4Off.SetActive(false);
         }
         else
         {
             button4On.SetActive(false);
             button4Off.SetActive(true);
         }
 
         if (button1State == true && button2State == true && button3State == true && button4State == true && playFinalAnimation == false)
         {
             winBossBattle = true;
             StartCoroutine(WinBossBattle());
             Debug.Log("Win");
             playFinalAnimation = true;
         }
     }

Here's the Update() function at least but I don't think it will help in any way...

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

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

Related Questions

NGUI - Vector 3 Position different from position 1 Answer

Finding position of a GameObject using its name? 1 Answer

Vector3 sets to different coordinates than specified 1 Answer

how to find direction between two points 2 Answers

Aim Down Sights Positioning Problem 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