Particles that follow player


I have a particle system attached to my player. I've been trying to get the particles to follow the player when they move...What I think I need to do is to get the position of the Particle Emitter component and then take the difference of the players position. I think that I am missing something because I see no trail (which is what I am expecting) in the general area of where the player moves too.

I want to acheive a similar effect like dragging the Particle Emitter arbitrailly in the world, --dragging would represent the player moving in this case.

I might add that the particles are instantiated before this code updates.

`if (Vector3.Distance(Player.lastPosition, Player.myPosition) > 0.01f) // we moved
Player.lastPosition = Player.myPosition; // Update our Position

    if (Player.ParticlePrefab != null)

// Get the difference of our two positions

FollowTarget =  Player.ParticlePrefab.GetComponent<ParticleEmitter>( ).transform.position - Player.myPosition;

        if (Vector3.Distance(FollowTarget, Player.myPosition) > 0.01f)

//We are already emitting…
Debug.Log(Player.PartriclePrefab.GetComponent( ).position);



I think that it is right to get the ParticleEmitter component, but I am seeing a Transform component..Since my particles are already instantiated, wouldn't take up less memory to use the Transform component instead?

You don't need to do any coding if you want to attach your emitter to your player, simply make the emitter a child of the parent (drag the emitter onto the player object in the hierarchy window), and then reset its position to (0, 0, 0). This will make the emitter "follow" the player no matter what. You can also tick the "`Simulate in Worldspace?`" button in the emitter properties, so that when the player moves, the particles will not.

I already had the same problem, when i desing a shot particles to a gun, in a fps game. Every time i play the particles, the sparks of the particles stayed in the position that the particles are played, but the player moves, and the sparks coming in the camera. I solved it change the property “Simulation Space” of sparks particles to “Custom”, and assign the end of barrel of the gun. So, the player moves and shot, and the sparks follow the “gunEnd” GameObject (wich is in front of gun).
(Sorry for bad english :smiley: )

Hi, @lampshade @qJake
In my case putting the Particle System below an object (as child) and applying Fixed Joint solved the problem of linking the particle to an object.

  1. Place the particle system as a child of an object;
  2. On the particle system add component → fixed joint and attach it to the object.
    Hope this will help you! :slight_smile: