Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding ObiEmmitor gameObject in code
#8
(16-03-2018, 02:16 PM)shtolyan Wrote: Hello! Thank you for the wonderful asset
Can you help me with the problem of creating an emitter in the code? The object is created on the scene, all obi objects are configured, but the render does not work.


[Image: -o3QSG2tnohlkRdAU6fe4bzLjCN7hFBsL7ufMg94...=2048x2048]

*removed code part*

Thank you!

I think I found your problem, because my problem was pretty much the same. When you start the Unity project and the emitter with the particle renderer is disabled, the camera with the fluid renderer does not seem to be able to find it when it is enabled again.

I guess I will have to look into the code a bit to figure out what might cause this. I am guessing taking a part of its awake script and make it something it checks now and then could help fix this, making it possible to instantiate emitters at runtime.

(28-03-2018, 12:14 PM)josemendez Wrote: Hi there,

I think you're confusing the emitter material (http://obi.virtualmethodstudio.com/tutor...rials.html) with the fluid rendering material (http://obi.virtualmethodstudio.com/tutor...ering.html). The first one dictates physical properties of the fluid, the second one influcences how it looks. None of the parameters in the emitter material influence rendering in any way, they only influence the physics.

ObiFluidRenderer will use the materias you specify in its inspector. There's two materials involved in rendering fluid: the color blending material, and the fluid material.
Make sure you are using a material with the dielectric fluid shader as the "Fluid material", and the fluid colors blend shader for the "Color material", just like in the viscosity, mill, and faucet examples.

Then, you can control fluid smoothness, cloudiness, refraction, thickness, etc in the material itself.

Regarding emission: set the emitter's speed to 0 to stop emitting, set it back to any value you wish to resume emitting. As in any real-world faucet, the emission speed and the volume emitted per second are linked to ensure a continuous stream, with minimum fluctuations in pressure.

I found my problem. My emitter was inactive / deactivated when the Unity project started and got enabled as I fired the gun. Which I guess the fluid renderer does not like. I still have one mystery though... whenever I activate the gun, by changing its emitter from 0 to 3 now, it still causes the faucet emitter to also emit particles. Any idea what might cause that?

I have made the emitter transform and its Obi Emitter script public so that I can ensure that the gun targets the two directly. I used a gameobject.find before, but even then it only found one, the one it was supposed to. Now I dont use that, and it still emits from both the faucet and the gun.

Also it would be nice to know if there is a way to use two different fluid materials at the same time? Right now the camera seems to decide which material the fluid has, rather than the emitters and the particle renderes on them.
Reply


Messages In This Thread
RE: Adding ObiEmmitor gameObject in code - by Caldor - 31-03-2018, 09:20 AM