• 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 chearner · Jun 12, 2010 at 07:58 AM · positionparentchildrelativehold

How to hold a child objects position relative to parent as it moves.

I have a particle emitter that I need to planted, always 10 units from camera on z plane, as the camera spins and moves. I want to emitter to stay x = 0, y = 0, z = -10 units from my camera and always face the camera to send particles it's way.

The camera can move around in space and spin 360, if the camera spins 180 it will be facing the emitter rather than the emitter spinning around as a child object would behave.

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 Novodantis 1 · Jun 12, 2010 at 08:32 AM

I'm not sure I understand this correctly, but if you parent the emitter to the camera it should stay in the same position relative to the view, that happens automatically.

If you want the emitter object to follow the camera's position but not it's orientation, attach to it a Follow script (note; object must be unparented for this to work properly):

var offset : Vector3; var targetObject : Transform;

function Update() { transform.position = targetObject.position + offset; }

Where targetObject is set to the camera and offset is the desired local coordinate of this emitter. You can make this script much more automatic and clever of course; it's just a start point.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Add force to Child while it's parent rotate around something..... 0 Answers

Where to find original unity Parent/Child script? 2 Answers

Find Child's Position Relative To World (Global Position) 1 Answer

Make a simple tree 1 Answer

How can I identify a non-uniform scaled mesh, and fix it? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges