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 nongenre · Jun 09, 2012 at 05:39 AM · rotationinstantiateprefabprefabs

Preventing parts of a prefab from rotating w/parent?

I'm sort of new to creating complex prefabs, and am having a couple of issues that I think are just a result of my inexperience. My prefab is made up of three parts:

  • Turret Top

  • Base for the Turret

  • Dummy Node (used as instantiate point for projectiles)

The "Turret Top" object carries a script which handles rotating itself to track the mouse, firing projectiles, and attaching the dummy Node to itself. It is also the top-level of the prefab. The other two items show up beneath it in the Project view. TBH, I'm not really sure what the significance of hierarchy is here (and probably should).

There are two issues I'd like to solve:

  1. When I instantiate this prefab, it uses the pivot of the Turret Top object for placement. I'd prefer to use the pivot of the Turret Base. Is there a way to do this? Should I just re-build the prefab with this as the top-level item, or does that carry other ramifications?

  2. When my Turret Top is rotating to track the mouse, the Turret Base is moving with it. Can I tell my prefab not to do that? I just need the Base there visually, and when I create my "real" art I'd much rather just build two meshes and rotate one completely, as opposed to having to create an actual animated object.

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 Fattie · Jun 09, 2012 at 08:18 AM 0
Share

I'm not entirely clear what you're asking, but...

  1. write some code that sets the turretTop to be, however you want it. You may well use things like "LookAt" to make it look at some distant mountain or marker point.

  2. write other code that sets everything else, to be, how you want it to be.

  3. when you instantiate the object. run the code mentioned in 1 and 2. (ie, very likely in "Awake()" or "Start()" .. or something like that ... or called from the thing that instantiated it.

in this way the things mentioned in 1 and 2 will be done to your stuff. and everything will be how you want!

PS a handy tip I have found when getting started. Just FORGET about prefabs. Have one of your tanks/whatever simply SITTING OFFSCREEN. then, instantiate it as a new one. and position it, and so on, and run the code mentioned in 1 and 2.

i just find that easier somehow than worrying about prefabs.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Prefab always spawns with the wrong orientation 2 Answers

Need help understanding scripted prefab behavior - when I click one, the script runs on ALL prefab instances, not just the one I clicked. 3 Answers

how to call the animation of prefab 0 Answers

Unespected rotation for Instantiate object 1 Answer

Instantiating prefab of object like it was in the scene 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