The question is answered, right answer was accepted
Particle system displacement caused by Android camera switching
I'm doing an android APP, and I came across a button that swap the android device camera back and forth : - when the device use its back camera( CAMERA_BACK,CAMERA_DEFAULT ), the particle system works as intended. - when it change to front camera( CAMERA_FRONT ), the UI flipped horizontally so I have to manually flip it back...... AND the particle system went all wrong , it turn itself upside-down and the position is all messed up. I tried to manually flip particle system as I did to UI but it went worse, the result is totally unpredictable. I believe it not only flips but also rotates. so... HELP ~~~~PLZ~~~~~~OTZ~~~~
screenshots:
You're not supposed to flip the UI manually which only complicates things. If you're using the built-in canvas UI, change back to "Screen Space - Overlay" or use a dedicated camera only renders the UI layer if you insist "Screen Space - Camera" (subsequently remove the UI layer from other cameras' culling mask). If you're using NGUI then I have little knowledge about it.
thanks your comment ! but I tried "Screen Space - Overlay" too, and then the firework effect is too tiny to visualize.
Then move the camera closer to the fireworks if it's perspective projection or change camera "size" if it's orthographic.
I check back and found I didn't flip the UI ( maybe I did that last build ), but the fireworks is still upside down... the whole function is now like this:
just simple camera-switching. nothing more.
and the setup:
Perhaps you can record a video of your editor to show both the scene view and game view. If the fireworks appear upright in scene view, the only problem could only be the rotation of your camera.
thanks as always, and what do you mean by "rotation of the camera" ? all I did is switch back and forth. and I can't record a video cuz I have no android simulator or sth., all I can do is test my APP in the Android device that connected to my PC. so obviously when I enter play mode in Unity, the camera won't turn back and forth( cuz it doesn't have any ) and the fireworks looks great!
Then you may parent the whole effect object under the camera so it's always upright.
parent the whole effect object under the camera
I've tried. no. still hanging there. upside-down, mocking my patient.
it's all about Android's " CA$$anonymous$$ERA_FRONT " I think. everything is fine in CA$$anonymous$$ERA_BAC$$anonymous$$, even when I change from front to back, the particle will appear normal again too. I started to wonder maybe there's some built-in mechanisms in android platform or sth.
Sorry I forgot to add that about the parenting method: If you find that the simulation space of the main/velocity/force modules are "world", change them to "local", but you do need to do some extra work (switching values between x/y/z axis) to ensure the fireworks are still upright in the scene view. And then you test it by rotating the camera upside down in the editor to emulate the scenario in the phone.
I hate to say that I've tried this too... it's not working, even custom and bind a transform to them, no. that's why I went crazy and came here for help..
all I can think about is make every firework animation depends totally on gravity, and manually negate the gravity when camera switches, I'll go for this now wish me luck... or..
Answer by ifurkend · May 16, 2017 at 09:54 AM
It's a lesson for me as well. The unity camera which renders what the camera in reality captures serve as the base camera (lowest depth) without rendering other scene objects, otherwise things will rotate unexpectedly. Then create another camera with "depth only" clear flag and higher depth value for rendering the rest of scene objects.
Answer by Yuzuke · May 16, 2017 at 07:53 AM
Or you use "Screen Space - Camera" mode in UI canvas and add a separate UI camera which only renders UI layer (and remember to remove "UI" layer from your AR camera), then change the layer of all firework objects to "UI", effectively making all the firework particle systems part of the UI elements.
@ifurkend I'm not sure if I already did this but I'll do this now. thanks for your patient.
@ifurkend but the fireworks is supposed to overlay on the AR images, how can I do this if I use 2 cam to separate those.. I don't quite get it.
The final rendering result automatically combines all effective cameras. The order or rendering depends on the "depth" value in the camera component, the greater depth of the camera, its objects will appear before others rendered by camera with lower depth value. As long as you don't rotate the UI camera (or let other script rotate it), the fireworks rendered by this camera should remain upright.
@ifurkend IT WOR$$anonymous$$ED!! , the firework's no longer upside-down. HURRRRAY!!!!!!!!!!!! BUT the only problem now is the UI Camera's setting. cuz now it only shows black screen. and the UI elements and the fireworks. ID$$anonymous$$ whats wrong but I cant upload images right now, so:
for the clearflag I use solid color and make it totally black, also set the alpha to 0 as ARCam currently has, and I use orthographic projection, and for the culling mask: ARCam is everything except UI, UICam is everything( or UI only it makes no difference to me, all black )? and the rest of the setting just default. and also depth is fixed, 0 for ARCA$$anonymous$$ to stay behind, 1 for UICam to overlay up top.
where went wrong? what am I missing?
Follow this Question
Related Questions
Particle System not showing up in game view, showing up in scene view 13 Answers
can i find whats the problem of the script of free camera rotation ?? 1 Answer
Particles invisible in bottom half of game viewport 0 Answers
How to use External camera on andorid 0 Answers
How to move camera with Input.GetAxis() and my camera view direction?!! 1 Answer