Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 hardmode2236 · Nov 21, 2014 at 03:48 AM · cameratransformpositiony

moving a transform by 10 but it goes exra...

this has me totaly stumped.

im telling my camera to move down 10 like so:

 function initCam()
 {
     cam.transform.position.y = -10;
 }

and for some reason when i test the app it goes from 0(its starting Y position) to -11.10805. i cant imagine why it would blatantly ignore what i have written in the script.

here is how its called:

 function OnGUI () 
 {
     if(totalTargets == 1)
     {
         if (GUI.Button(Rect(Screen.width*.1, Screen.height*.45, Screen.width*.15, Screen.height*.05), "Initialize"))
         {
             initCam();
             for(t in TargetedTargets)
             {
                 if (t == true)
                 {
                     targets[c].initNow();
                 }
                 c++;
             }
             c=0;
         }
     }
 }


side note: when i try to put it back to 0 using cam.transform.position.y = 0; it goes to -1.108051 instead. so far this is the first piece of code for moving the camera in this project. so it cant be any interference from any other scripts.

  • forgot my unity was out of date, could be some kind of error. i'm going to update and restart my PC or something, see if that fixes it.

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 jtok4j · Nov 21, 2014 at 07:16 AM

Hi Hardmode2236,

I recently lost some hair with this same issue... I was pulling my hair out, trying to figure out what the #)*(WGN was wrong with my coding...

It turned out that "After" I started playing my scene, the position of the object that I was moving with transform, actually was changed from where I thought it was.
It was a child object of a larger prefab, if I remember right.

So, it went like this: Object's transform y position was set at 0.
When I clicked "play" (that button) in the editor, I then went to the inspector, and saw my object's (the one I'm transforming) position (y) was not at 0 anymore, due to the placement of the parent object/prefab.

So, try to check and see if your object's run-time position is actually adjusted after the scene starts up. :)

Hope this helps.

Comment
Add comment · Show 2 · 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 hardmode2236 · Nov 21, 2014 at 07:24 AM 0
Share

ahhh yess, thats it. my 'world' object which is a parent to all objects in the scene wasn't at (0,0,0). i set it right, now my camera is perfect. thanks for the insight :)

avatar image jtok4j · Nov 21, 2014 at 07:25 AM 0
Share

Sweet! :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

27 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

Related Questions

Change position of camera on scene load? 1 Answer

When switching camera position... 1 Answer

Help! I want to make a following camera but in with Y position is constant ? 2 Answers

Detect whenever the player is near the edges of the screen 2 Answers

Set Game Object Position to Sides of a Camera 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