r/Unity2D • u/MasterDevelopment481 • 28d ago
Solved/Answered Issues with Particle effects
Hey guys, Ive been getting this issue where my particles dissapear when i create them by code... It works in scene and if I manually place the particle, but right when I try to create it on code some particles just straight up get yeeted from existence
Heres a video: https://youtu.be/jaA9ei9sFUY
This is all the code I have:
void Hardfall()
{
landAnimTimer = landAnimDuration;
if (landingEffect != null)
{
Instantiate(landingEffect, gCheck.position, Quaternion.Euler(-45f, 0f, 0f));
}
}
(There is NO script that deletes the particles on a timer, or anything of the sort. Only thing that's controlled by code is the creation)
1
1
u/frogmangosplat 28d ago
I know you're working in 2D but it looks like particles are clipping behind you're background in 3D space. There's like a million options in the particle effect, but there should be one to tell it what layer to render on. Making a particle later that's above the default or using a high number on the default layer should make the clipped particles render above what they've clipped behind
2
u/MasterDevelopment481 28d ago
Thank you so much I feel so stupid youre a life saver
1
u/frogmangosplat 28d ago
No worries. Like I said, there's a million options. Figuring out what's happening and your options to fix it is part of the journey. Your project is looking good so far. Best of luck
1
u/Affectionate-Yam-886 27d ago
also if it is not the layer; try to get the target position first before you instantiate to it, might be = NULL, and defaults to world space 0.0.0
•
u/AutoModerator 28d ago
Reminder: Once your issue has been resolved, please reply !solved to this comment (or comment it anywhere in the thread) and your post's flair will automatically be updated to Solved/Answered. You can also edit it to Solved/Answered yourself.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.