3
\$\begingroup\$

I am rotating a gameobject that has a child game object with a particle effect on it.

It's a missile with engine exhaust.

enter image description here

I am rotating the parent game object but the particle effect child objects do not rotate:

enter image description here

The missile object has this script on it:

void FixedUpdate () {
Vector3 dir = targetObject.position - transform.position;
dir.Normalize();

float zAngle = Mathf.Atan2( dir.y, dir.x ) * Mathf.Rad2Deg - 90;
Quaternion desiredRotation = Quaternion.Euler( 0, 0, zAngle );

transform.rotation = Quaternion.RotateTowards( transform.rotation, desiredRotation, 10.0f * Time.deltaTime );
rigidBody.AddForce( transform.up * 10.0f, ForceMode2D.Force );
}

Particle Effect:

enter image description here enter image description here

Anyone see what I am doing wrong?

\$\endgroup\$
  • \$\begingroup\$ Yep, we see! Show us the screenshot of your ParticleSystem component. If you're using the VelocityOverLifetime module, set your SimulationSpace of the particleSystem to Local instead of World. \$\endgroup\$ – Jacob Jun 23 '17 at 21:34
  • \$\begingroup\$ @Spectre I have added the screenshot. I am using Local \$\endgroup\$ – user-44651 Jun 23 '17 at 21:47
1
\$\begingroup\$

The answer is on the Particle, under the Renderer, Change Billboard Alignment to Local. Thanks to @spectre for the idea of using Local.

enter image description here

\$\endgroup\$
-1
\$\begingroup\$

You are applying the rotation to the rigidBody component, which will apply transformation only to the object with the rigidBody, which the particle system does not have.
Note that the particle system will still be dragged along with the parent gameObject as it is a child of it, but it will not experience the force transformations. I would suggest to apply a Transform.Rotate to the particle system separately in the next line to match the parent rotation.

Read https://docs.unity3d.com/Manual/class-Rigidbody.html - Parenting section.

\$\endgroup\$
  • \$\begingroup\$ This is not the correct way. Please see my answer @raghavendra-singh-dasila \$\endgroup\$ – user-44651 Jun 25 '17 at 14:11
  • \$\begingroup\$ My reasoning is not incorrect however for the explanation of the phenomenon observed. Albeit your method is quicker and easy. @user-44651 \$\endgroup\$ – Raghavendra Singh Dasila Jun 25 '17 at 23:12
  • 1
    \$\begingroup\$ This answer is incorrect. Moving a rigidbody on a parent object will update that parent object's transform, and that modified transform will affect child transforms nested under it in the hierarchy just the same as manipulating Transform.Rotate directly. The documentation you cite talks about the opposite case: when the rigidbody is on a child object, it will experience physics-driven motion partly independently of its parent's transformation. \$\endgroup\$ – DMGregory Sep 4 '17 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.