World-Space Particles in Local Space?

Hello again!

I’ve got a small problem here… I’m trying to do a floating origin setup for my game (to prevent floating point problems).
The idea behind floating origin is that if your target object (usually a spaceship) gets too far away from scene zero (the origin), you move the ship back to scene zero, and displace every other object by the same amount, so that the universe moves around the ship, instead of the ship moving.

This makes it so that floating point errors only occur far away from the player’s position, so you don’t see any distance-related inaccuracies and problems.

Now, there are a few particle emitters in the scene that will have to be moved along in these origin shifts.
The problem is that the emitters are set to ‘simulate in world space’, so their particles won’t move if the emitter moves.
Since these emitters are doing smoke trails, having them simulate in ‘self’ space is not a very good option, since moving the emitter will drag the smoke trail unrealistically along with it (and even worse when you rotate it)

What happens now, when I shift the origin, is that every world-space particle in scene won’t move along with everything else, so you can see a trail of particles ahead of you when the shift happens.

What I need is to be able to shift the emitted particles along with the rest of the ‘universe’… so the shift isn’t noticeable.

Is this at all possible?

I thought about 2 ways of doing it, that hopefully someone here can confirm or disprove before I commit to one of them:

One, write a script to loop through each particle and shift it along. --Might work, but might also be slow.

Two, have the particles simulate in self-space, and by script manipulate the emitter center and orientation. This way, the particles will move when the emitter transform moves. The problem is that I don’t even know if there is a way to shift the emitter center without using it’s transform position.

What do you think?

As always, thanks in advance.

Cheers

I’m having similar issue. I have particles using ‘sim world space’ for a ship particle trail. It works well until my scene needs to be ‘tiled’ and the ship is moved to the new camera position for a tile edge swap. The trails do not move with the emitter. Fine… I’ll move them manually… too bad that doesn’t seem to work either. With sim world space the following code seems completely ignored:

//Move Particles
parts = GameObject.Find("BaddieEngineFlares").GetComponent(ParticleEmitter);
for (i=0; i < parts.particles.Length; i++)
{
	parts.particles[i].position.x += distX*2;
}

To move particles, you have to first assign the particle array from the emitter to an array of you own, move them there, then assign the whole array back to the emitter. (it’s weird, but it’s true)

like this:

//Move Particles

Particle[] parts = GameObject.Find("BaddieEngineFlares").GetComponent(ParticleEmitter).particles;
for (i=0; i < parts.particles.Length; i++)
{
	parts[i].position.x += distX*2;
}
GameObject.Find("BaddieEngineFlares").GetComponent(ParticleEmitter).particles = parts;

(of course, you can also store the components to variables to get rid of that ugly string of Finds and GetComponents :wink: )

Cheers

Another method you could do is have Local Space Particles on an emitter parented to a gameobject without a parent. Then you can keep that GameObject at 0 to simulate World Space Particles, but parent or move it to simulate LocalSpace Particles.

Hey I found this thread because I’m encountering the same situation.

@Ntero I thought this same thing, and it is what I did, but it doesn’t seem to work for me. Perhaps I’m doing it wrong.
I’ve created a particle emitter that functions in worldspace, therefore leaving particles behind. I put that in a parent empty gameobject that moves around, but this still leaves a trail of particles.

@HarvesteR hmm, I’m going to try this. I’m hoping it isn’t a huge performance drain, as I’m looking at simulating 30+ particle systems simultaneously onscreen.

just to follow-up with my experience - I have a puzzle game where I’m using a particle system for effect when a special piece is used. Actually it’s the “Burst” system from the Asset store free package “Simple Particle Pack” (THANKS). Anyway, I didn’t want to instantiate and destroy them over and over, and I wanted to limit the number in use for any one move, so I implemented a simple pool where I created two instances with “Play on awake” toggled off, intending to use them as needed; with the two PS’s parented to a GO in the heirarchy. I found that they don’t move around when you set the transform.position - that brought me here.

My solution was not to parent them to a GO at all, just let them sit at the root level of the hierarchy and keep refs to them in an array in code. This immediately solved my problem. So my guess is that if you have a pool of PS’s that something about the parenting to a GO that messes things up. But since I solved my problem I don’t expect to research this further - just wanted to pass this along.

BTW my PSs are in world space.

AUGH! (and other unprintables): how does this work in the editor and not in a built app on an ipad.