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 iamian99 · Apr 02, 2016 at 05:24 AM · rotationinstantiatechild

What would cause an objects transform to be different from its onscreen position?

In my game, I have a gun object which I am trying to get to shoot another bullet object. In order to instantiate the bullet object at the barrel of the gun instead of the center, I have another object placed at the barrel which I use as the position and rotation for my instantiate. This object is a child of the gun, so that as the gun rotates and moves, it will stay at the barrel. Upon running the game, I can see that the object stays at the barrel, even while the gun is moved and rotated. However when rotating the gun, the point at which the bullets are instantiated at does not change. Why is this happening and what could I do to fix 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
0
Best Answer

Answer by meat5000 · Apr 02, 2016 at 12:34 PM

Parenting and object will make the Transform information in the inspector show local instead of world space. It is relative to the parent and without the parent your object is parented to the world.

To a child, 0,0,0 represents the centre of the parent.

The Scene View issue is that the Handles you see in the window show the averaged centre of all the sub-objects in the hierarchy of each object. To test this, make a bunch of objects and child them to each other, deep as you like. Take the bottom-most child and move its position to something further away. Click back on the top-most parent and see where the handle has moved to.

When scripting it is important to take in to account world space and local space of a transform. The Transform class has several methods for dealing with converting from one to the other.

These are called TransformDirection, TransformPoint, TransformVector and their Inverses and now the Transform includes localToWorldMatrix and worldToLocalMatrix for use with shader parameters.

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Network.Instatiate Problem 0 Answers

Problems with instantiating a clone as a child? 1 Answer

How Can I Make an Instantiated Object a Child of Other Object? 2 Answers

Delay child objects rotation 0 Answers

How to instantiate on custom rotation? 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