Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Justin Warner · Dec 13, 2010 at 08:34 PM · gameobjectprefabparticlesystemmove

Prefab connected to empty gameobject with scripts, empty moves, prefab doesnt?

Hey, So, I have a prefab with a particle effect, which is connected to an Empty game object with scripts.

The script is a "damage" script, which shouldn't matter, but the other script is a move script...

Looks like:

var speed = 1; function Update () {

 var dir = Vector3.up;
 var relative = transform.TransformDirection(dir);
 transform.position += relative * -speed * Time.deltaTime;

 if(transform.childCount == 0)
 {
     Destroy(gameObject);
 }

}

What this does, is move the empty game object, but NOT the prefab that's a child to the empty game object...

Then, once the particle system runs out, it kills the empty gameobject too.

Problem is, the empty game object moves, but the child (The particle system prefab) does not..

So, question: How do you get it so that the child moves too?

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

2 Replies

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

Answer by boymeetsrobot · Dec 13, 2010 at 08:37 PM

Hey you need to set the transform of the prefab to the parent (empty) gameObject something like myPrefab.transform.parent = transform;

Comment
Add comment · Show 1 · 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 Justin Warner · Dec 13, 2010 at 08:48 PM 0
Share

Can't seem to figure it out with that... =/

avatar image
2

Answer by skovacs1 · Dec 13, 2010 at 09:13 PM

Your description is a bit confused:

In the Project view, you see a list of things. Pretty much everything listed here, except for folders is a "pre-fab" in a sense. The typical reference in Unity is to prefab GameObjects (indicated with the blue cube that has a piece of paper on the bottom-right).

In your Hierarchy view, the objects are instances. These instances may refer to the prefabs, but they are not the same thing. If you change a prefab, all linked instances that do not override the pre-fab will change. If you change an instance of a prefab, only that instance will change.

If I understand your situation, you should have a hierarchy like so:

Empty GameObject
    Particle System Prefab Instance

Empty GameObject has the posted script attached and moves.

Empty GameObject moves, but Particle System Prefab Instance does not? If this is the case, I can only assume that your hierarchy does not look like the above unless you've got some collisions or something getting in your way.

What boymeetsrobot was referring to was that in code, if you have instantiated your prefab as Particle System Prefab Instance, it will not be the child of Empty GameObject until you tell it to be with code like:

var prefabInstance : GameObject = Instantiate(prefab, transform.position,
                                              transform.rotation);
prefabInstance.transform.parent = transform;
Comment
Add comment · Show 5 · 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 Justin Warner · Dec 13, 2010 at 10:28 PM 0
Share

Still not getting it... I'll make a video and ask in another question...

They layout is right, but the particle system IS the prefab...

And I'm not getting that script part, I'll play around with it more none-the-less...

Thanks though...

avatar image skovacs1 · Dec 13, 2010 at 10:48 PM 0
Share

No need to go that far. Just say what you don't get and I can re-word the answer to be clearer. As I said, that script part is only if you instantiated your prefab in code.

avatar image skovacs1 · Dec 13, 2010 at 10:56 PM 0
Share

If your hierarchy matches the one above, then are you certain that you particle prefab instance's transform is not moving and that it is not simply the particles that you see are not moving? For example, does you prefab have a ParticleAnimator?

avatar image Justin Warner · Dec 13, 2010 at 11:31 PM 0
Share

It does have a particle animator... And that's what's happening... The prefabs transform is moving, but the particles aren't...

avatar image skovacs1 · Dec 14, 2010 at 03:21 PM 0
Share

The problem is with the prefab and its settings if the prefab instance's transform is moving, but the particles are not. I cannot replicate or identify the exact problem from this information alone. Perhaps you could share more information about your setup? What components do you have on your prefab? What are their settings, etc.? Or stepping through the process you followed to create your broken prefab: 1.GameObject/Create Other/Particle System. 2. Changed setting X. 3.etc. I would think it may have something to do with One Shot, $$anonymous$$ax Energy and Simulate In World Space.

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

No one has followed this question yet.

Related Questions

How to add a prefab containing Animation to a GameObject? 1 Answer

Adding prefab ParticleSystem to a GameObject? 0 Answers

Spawn blood particle system prefab where sword hits enemy 1 Answer

Why would the clone of a particle effect not work? 0 Answers

prefab is instantiating without a script 2 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