Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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
0
Question by StevieMac · Apr 27, 2012 at 05:05 PM · instantiatetransformprefabparticlesshuriken

How do I Update the transform of Instantiate prefab?

I have a prefab Shuriken Particle system & I want it to follow a rock after it collides.
Problems I have with this 1.I can get the particles to turn on when I want but not turn off as I can't access the prefab Shuriken emission.

  1. can't gett it to follow the rock the this script is attached to only be created where it collides. I think I need an update function but I don't know how to fit that in below.

Thanks for any help.

var Debris : GameObject;

 function OnCollisionEnter(){
         
         Instantiate(Debris, transform.position, transform.rotation);
  
          Emit particles for 3 seconds
         yield WaitForSeconds(3);
         //Then stop
         Debris.enableEmission = false;
         
  
 }
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

Answer by GerryM · Apr 27, 2012 at 06:19 PM

When "Debris" is your prefab, you might want to save the actual instantiated object which is returned by the "Instantiate" function. You can then access it's components like transform or the particle system.

 var actualObject : GameObject = Instantiate(Debris, transform.position, transform.rotation);
 // Wait...
 actualObject.transform.postion.x += 10; // move it
 actualObject.transform.particleEmitter.enabled = false;; // stop the emitter

Something along this, perhaps.

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 Owen-Reynolds · Apr 27, 2012 at 06:38 PM 0
Share

So, the answer is not to change the Instantiate prefab :-)

The Scripting Reference, only 1 click in under the Instantiate heading, also shows this trick. The links are laid out a little funny -- sometimes the best way to navigate the official Unity Docs is with google, but they really do have examples of the "right" way to do almost all of the common stuff.

avatar image
0

Answer by StevieMac · Apr 27, 2012 at 10:36 PM

Sorry guys this is really hard for me to get my head around as I'm an artist not a coder. So try to make it as simple as poss. Thanks for the help!

So I have a prefab called Debris & an animated Rock you saying to put the script on the prefab instead of the rock to access the the components of it?

I tried this but got an error.... Assets/Scripts/Prefab Scripts/Rock_Debris.js(1,45): BCE0005: Unknown identifier: 'Rock_Particle_Debris'.

var actualObject : GameObject = Instantiate(Rock_Particle_Debris, transform.position, transform.rotation); // Wait... actualObject.transform.postion.x += 10; // move it actualObject.transform.particleEmitter.enabled = false;; // stop the emitter

Comment
Add comment · Show 2 · 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 GerryM · Apr 28, 2012 at 01:07 PM 0
Share

$$anonymous$$aybe you could describe what you want to accomplish game-wise? Should the Rock disappear when the Debris appears? Then the scripts in each object can't refer to each other. You could try a separate (empty) object which contains a kind of manager script. Inside that script you should instantiate (or delete) all the objects you need, keeping a reference. Then you can access the components of these objects easily.

avatar image StevieMac · Apr 30, 2012 at 02:39 PM 0
Share

Hi Gerry I'm not making a game its a demo for showing I can do particle FX in games. So I have a character with Animation's brought in from 3ds $$anonymous$$ax, that are triggered when the button on the side of the screen is pressed. So I have a button for Earth, you press this & the character smashes the ground a boulder rises & he kicks it away like a special move, this all works fine!

I have my particle FX working I just need a way of triggering more than one at the same time as the rock rises & one of the FX has to be attached to the rock as it rises.

So you press the button on the side, the animation plays & tiggers the FX. The Rock does not disapear it's jus animated off screen to reset to a position under the ground to be used again when the button is pressed again. I have 4 animation's altogether all on the same time line & this Rock/Earth one starts at 78-116. Originally I was hoping just to animate the FX on & off using a timeline but I've read this isn't the way to go about it. So now I'm using the collision route where as the rock collides with the ground, it triggers the FX which I have working but I need to get the debris to fall off the rock so it needs to be attached to it as it rises. I read you make a Prefab then make this appear where the rock does but I need it to follow the rock as it rises this is my problem.

So am I doing this all wrong?

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

How to follow multiple clones positions of an instantiate prefab having a velocity ? 1 Answer

Can't remove instantiated prefab 0 Answers

Putting prefab into scene messes with the transform origin? 1 Answer

How to Destroy Particle System after Instantiating,How to destroy a particle system that was just spawned? 1 Answer

Instantiated Object looses prefab's rotation 10 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