V
V
Vqrlamov2022-03-11 14:51:14
Unity
Vqrlamov, 2022-03-11 14:51:14

How to block movement on the Y Particle system?

There is a Particle sistem which is a child of the player. The player moves, the Particle sistem moves with him. The Particle sistem settings are set to Simulation space - World.
Is there any way to block the movement of the Particle in Y, provided that the player can change the position in Y?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
K0TlK, 2022-03-13
@K0TlK

Create a separate script that will move the particles, hang it on the player, do not make the particles children of the player.
Something like this:

public class Particles : MonoBehaviour
{
    [SerializeField] private ParticleSystem _particle;

    private void FixedUpdate()
    {
        MoveParticles();
    }

    private void MoveParticles()
    {
        var position = _particle.transform.position;
        position.x = transform.position.x;
        _particle.transform.position = position;
    }
}

We place the particles in the inspector and that's it. I have a project in 2d, so there is no z-axis, but if you have 3d, then the z-axis also needs to be moved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question