- Home /
Particle bug... wrong location. Simple code
Hello,
I posted this before but the issue couldn't be solved. I now have a hunch of what might be causing this but am still unable to fix it. So I'll describe the problem again.
I have a very simple code and it bugs sometimes. Unfortunately it happens very rarely and all my attempts at debugging it failed since I can't even replicate it at will.
What happens is - I have a sprite and a particle. When certain even happens, this particle should be moved to the sprite's position and played:
public void FunctionXYZ()
{
Particle.transform.position = new Vector3 (sprite.transform.position.x, sprite.transform.position.y, -3);
Particle.Play();
}
The rare bug that occurs is that sometimes particle doesn't play from the sprite's position but from some random position on the screen.
I think this might be due to the fact that FunctionXYZ()
is called from OnTriggerEnter2D, so it's a FixedUpdate() and maybe it comes in conflict with something. I don't know. I tried putting waitForEndOfFrame
and waitForFixedFrame
at the start of functionXYZ()
and it didn't help.
I have no idea why this is happening, I've been coming back to this bug for a week already and I still can't fix it.
If anyone can help, I'll be very grateful.
P.S. the issue does not lie in the local/global positioning. I checked.
Your answer
Follow this Question
Related Questions
Teleporting old particle system 0 Answers
Instantiate in different position 2017.3.0f3 2 Answers
Transform position not changing. 2 Answers
Y position changes randomly,Y position changes weirdly 0 Answers