Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So I'm using Unity's simulate function to pre-render particles. It seems that simulate is not quite working as to what I expect. It's most likely a setting that I missed. But I just really cannot find the issue.

This is from inside the editor, I clicked on the particle object and just let it run This is from inside the editor, I clicked on the particle object and just let it run. This is what I'd like.

This is after I've run the game a little bit, then hit pause This is after I've run the game a little bit, then hit pause. This is what is currently happening, for some reason the particles get bigger.

Here is the script that I've attached.

public float initTime;
public ParticleEmitter partEmitter;
// Use this for initialization
void Start () {
    for (float i = 0.1f; i < initTime; i = i + 0.1f) {
        partEmitter.Simulate(i);
    }
}

I've run this scene in both Unity 3.5 and in Unity 4.0. Same thing happens in both versions.I'm pretty sure that it's something to do with the script. But I've tried many different pieces of code and they are all similar and do the same thing.

share|improve this question
    
Have you changed your physics time step amount? I had a weird issue where the simulated particles would behave differently if I had the fixed time step set to anything other than the default (.02 I think). –  Tetrad Jan 16 '13 at 18:30
    
@Tetrad Are you talking about my step in the for loop(incrementing of i)? I've just tested that. A smaller amount makes the particles bigger and vice-versa. If you speaking of the step setting in Time settings, I haven't changed anything there. –  Vincent P Jan 16 '13 at 19:21

1 Answer 1

up vote 1 down vote accepted

The function documentation states:

function Simulate (deltaTime : float) : void

That is, the function parameter is a time delta, a step in time. It is not a certain moment in time.

Physical simulations work based on discrete steps in time. And the stability of many simulations (or rather the error within a simulation) is directly related to the size of a time step you take.

In your code, you're taking increasingly large steps in time. While single particles might put up with that for a while, given a sufficiently large step they might start to become unstable.

Most likely your problem will be resolved by taking a number of fixed time steps of a relatively small size.

public float initTime;
public ParticleEmitter partEmitter;
// Use this for initialization
public float deltaTime = 0.1f;
void Start () {
    for (float i = 0.0f; i < initTime; i += deltaTime) {
        partEmitter.Simulate(deltaTime);
    }
}

I have taken your 0.1f here (a tenth of a second), but this might have to be even somewhat lower.

share|improve this answer
    
Your right in that you cant keep passing a bigger number to Simulate. –  Vincent P Mar 13 '13 at 17:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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