Unity Particles - Need to set rotation - nothing I've tried works

Screenshot 2024-04-17 at 7.40.46 AM

Screenshot 2024-04-17 at 7.41.15 AM

In this game, I have a rocket and use particleSystem to generate the flames. It works perfectly except it does not rotate when the rocket rotates.

I have the flames nested into my rocket, but that does not affect angle.

Screenshot 2024-04-17 at 7.45.09 AM

I have poured through the settings for the particleSystem and even tried a few scripting ideas, but nothing seems to sync the rotation / direction of the particles themselves.

The repo is here: https://github.com/JerryHobby/Project-Boost

The game can be played here: https://godot.jerryhobby.com/projectboost/index.html

All my google searches find things that are either outdated and quite vague. Appreciate any insights into this.

Jerry

Hi Jerry,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime?

If the relevant code gets called, check if your component references the particle systems of the children of the rocket.

A common mistake is to assign the particle systems of the prefab to the field. In this case, Unity ‘plays’ the particle system, which is not in the scene, and you won’t even get a warning.

I created particle systems as child components of my rocket. But they were not honoring their parent’s position. The solution turned out that I needed to put the particle system directly on the rocket. I’m sure there are multiple ways to do this - but that solved it for me.

There is a lot to learn about object relationships in Unity. I see that the particle system uses a billboard. I’m sure that’s what you were talking about.

The only weirdness, probably due to the billboard, is that the flame effect scales differently when I am editing the component. It feels like the billboard might be positioned differently making the camera view look different than the editor view. I’ll sort that out later.

Motto for developers: Everything is harder than it should be. :slight_smile:

Thank you again Nina. You’re my hero once again.
Jerry

The difficulty I had was because I was ahead of the course a bit. I was trying to get a reference to my thrust-fire animation via code. When I got caught up with the lesson - he used a SerializedField to get the reference to the particle system component. Once I made those changes, everything worked perfectly.

That’s what I get from always trying to solve coding challenges before the instruction. Now that I’ve had the instruction, it’s a piece of cake. Do it right and you won’t do it wrong. :slight_smile:

In my personal opinion, it is usually better to try to solve a problem yourself first, then check other people’s solution. It does not matter if you ‘fail’ because trying to find one helps you learn more about the inner logic of Unity than you could ever learn from an instructor or a manual.

Getting a reference via code is tricky in Unity because GetComponent and FindObjectOfType return the first objects they find, whatever Unity defines as ‘first’. Unless you are absolutely sure that you have only one object of the type/name in the context you are searching (e.g. the entire Hierarchy with a Find* method, or a game object with GetComponent), it is usually better to assign a reference manually, not via code.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms