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
1
Question by sloanpnauts · Oct 15, 2015 at 06:12 PM · spawningparent-childeffectsinstantiation

Particle effect spawned lags behind parented object

I have a gun barrel and I spawn a particle effect at the end of it when the gun fires. Everything's OK when the gun isn't moving, but if the player does move, the effect is spawned, but is offset from the barrel.

I have the effect in the scene and I use Instantiate() to create a copy of it. I then set the transforms like so:

 effect.transform.parent = spawnPoint.transform;
 effect.transform.localPosition = Vector3.zero;

Where 'spawnPoint' is the end of the barrel. I've stepped through the code and everything looks OK. This also effects anything else spawned from this point. E.g. bullets. They look like they're firing from outside the gun when the player is moving.

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 Le-Pampelmuse · Nov 08, 2015 at 12:52 AM 0
Share

I have the same problem with a Particle System, the visual origin lags behind when the parent is rotating BUT additionally the visual origin stays at the same Y-offset to the parent, which makes absolutely no sense.

Particle Systems are obviously bugged since a couple of weeks.

Do you have a animated humanoid character as parent? Is the gun animated somehow? I believe it has to do with this, because I tested it with plain emtpy gameobjects and scripted the parent one to rotate, and the visual origin was dead on the gizmo!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eudaimonium · Oct 15, 2015 at 06:28 PM

The spawnPoint obviously isn't correctly set, then. I assume this is an empty Game Object somewhere within your character hierarchy? Double check what it is parented to - it's very important.

Probably the parent of that game object is wrong and it needs to be moved to a node that controls the gun position (or something similar, depends on your setup).

To debug, simply place a small cube or whatever at the spawnPoint and see what happens in the game, how does it move. Re-parent it and try again.

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 sloanpnauts · Oct 15, 2015 at 06:39 PM 0
Share

It's parented correctly. I added gizmos to the end of the barrel and they follow lock-step with the player movement. It's only the effect that lags behind the action. I checked the code and it sets the correct position; the effect position is correctly set to the end of the barrel position.

Here's a screen grab of the code after a run through:

alt text

spawnpoint-lag-1.png (7.0 kB)
avatar image Eudaimonium sloanpnauts · Oct 15, 2015 at 07:21 PM 0
Share

Perhaps the particle effects you're trying to spawn (muzzle flash I assume) is in World space, and therefore once spawned stays in the same place - is that the problem you're trying to solve? Basically what you need to do is go to the particle prefab you are using, and find the World Space / Local Space simulation switch, it's somewhere in the last tab "Rendering" I assume. This makes even the spawned particles follow your object ins$$anonymous$$d of just floating in the world.

avatar image sloanpnauts Eudaimonium · Oct 15, 2015 at 08:01 PM 0
Share

The effects were in local space, changing to world space made it worse, as you suspected. Problem is not just with muzzle flash, I also spawn a projectile at the end of the barrel and assign it the end of the barrel position, but it lags behind too.

I managed to screen shot the effect. The gizmos are at the spawn point (effectively the end of the barrel, it's currently the middle of the gun, but whatever). This is the point that I'd expect the particle system to spawn at, what happens though is it spawns several units away.

alt text

spawnpoint-lag-2.png (24.6 kB)
Show more comments

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GameObject Parent-Child instantiation order 2 Answers

How can I instantiate a unique game object? 2 Answers

How to spawn objects using an array of spawn points w/o intersecting 1 Answer

why my ClientScene.RegisterSpawnHandler deosn't work? 1 Answer

Is there a Limit to scene size? 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