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
1
Question by Kusho · Nov 20, 2013 at 11:00 PM · gameobjectlookatpositioningnot-working

Putting objects inside an empty GameObject changes the original position.

So i'm new to unity, and i'm trying some things before going for a Tower Defense game.

I checked the LookAt function with a camera pointing a simple object(like cubes), and it works fine. I also tried with simple objects facing other simple objects.

Then, i make a "Enemy" which is composed by cubes and spheres, and a "Tower" which is made from cylinders and spheres. The tower is divided on two parts: base and top, and top part should face the Enemy.

Here is the "fail". When i use the LookAt function, if i move the Enemy, the tower starts doing an orbit-like move too, instead just facing the enemy. Then i try the same thing with a simple object facing the enemy, and it works, but i observe that the object looks to a point which is different to the actual position of the enemy. Like if enemy has a "real" position and a "fake" position.

I confirmed this by adding a sphere collider to enemy, and -what a surprise- it appears just at the point i mentioned.

Why this happens?

Comment
Add comment · Show 1
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 PhilRousse · Nov 26, 2013 at 02:30 PM 0
Share

@$$anonymous$$usho: Don't forget to say what answer respond to your question.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by meat5000 · Nov 20, 2013 at 11:07 PM

When you parent one object to another, the transform of the child becomes relative to the parent. The transform of the child in the inspector is local transform. A child object will also move with the parent.

In hierarchy, a gameobject dropped onto another gameobject becomes a child of that object.

Comment
Add comment · Show 3 · 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 Kusho · Nov 26, 2013 at 01:57 PM 0
Share

Thanks, man! I cannot upvote, since i'm a newbie, but i wanted to do it! :D

avatar image PhilRousse · Nov 26, 2013 at 02:28 PM 1
Share

When a object don't have parent, it show is world position. (In reality, is parent is the world)

In script, you are still able to access is World Position:

 transform.position //Give world position
 transform.localPosition //Give position relative to the parent
avatar image PhilRousse · Nov 26, 2013 at 02:31 PM 0
Share

@meat5000: I would suggest to use the Community Answer feature, it allow other to edit your answer. Because I feel you answer the question, but wanted to add info. At first, I've created an new answers, but feel like it was s$$anonymous$$ling.

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

19 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

Related Questions

Is there currently a problem with .LookAt when using it in a script thats attached to a GameObject vs the Main Camera? 1 Answer

Trouble with positioning 2 Answers

get object with tag for LookAt(); 2 Answers

Change LookAt Face 1 Answer

View an array of the transform position/rotation of all game objects with a specified tag., 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