Hello, I'm a newly-purchased user of this package, and I noticed in your AO Spinning Cylinder Custom Fluid Effector Demo video that it effectively simulates the airflow generated when wind interacts with 3D objects. However, I couldn't find specific instructions or demo files on how to achieve this effect. I would like to inquire if the package provides any methods that can be referenced or if there are any techniques to achieve this effect.
Thank you!
Hi Michele,
Sorry for the confusion here, we've released the flow primitives update since this discussion so it should now be much easier to produce these effects. You can now create a flow primitive and add that to your scene. Flow primitives have the same "VelocityFunction" that fluid zones have. We separated the volume/zone and the flow behaviour into two classes for clarity in their use, this means that a flow primitive will affect everything in a scene unless it is contained inside a Fluid Volume, i.e. it is a child of a game object with that component attached.
An example flow primitive script would look like this:
using UnityEditor; using UnityEngine; namespace AerodynamicObjects.Flow { public class FlowRoundCylinderDemo : FlowPrimitive { public AeroObject cylinder; public float freeStreamVelocity = 1; public override Vector3 VelocityFunction(Vector3 position) { // Get the position relative to the cylinder's position position -= cylinder.transform.position; // Assuming the cylinder is extruded along the z axis for simplicity float radialDistanceSquared = (position.x * position.x) + (position.y * position.y); float radialDistance = Mathf.Sqrt(radialDistanceSquared); float cylinderRadius = 0.5f * cylinder.dimensions.x; // Non-physical, we're inside the cylinder if (radialDistance <= cylinderRadius) { return Vector3.zero; } float cosTheta = position.x / radialDistance; float sinTheta = position.y / radialDistance; float omega = cylinder.rb.angularVelocity.z; float circulation = -omega * cylinderRadius * 2f * Mathf.PI * cylinderRadius; float rr = cylinderRadius * cylinderRadius / (radialDistance * radialDistance); float vr = (freeStreamVelocity - rr) * cosTheta; float vtheta = (-(freeStreamVelocity + rr) * sinTheta) - (circulation / (2f * Mathf.PI * radialDistance)); return new Vector3((vr * cosTheta) - (vtheta * sinTheta), (vr * sinTheta) + (vtheta * cosTheta)); } } }
Please note that I haven't been able to test this - if you have any issues with it please let me know and I'll look into it in more detail.
Best wishes,
Conor
I have the same question! Can you provide more information? I'd like to try to replicate the AO Spinning Cylinder Custom Fluid Effector Demo with different shapes, like an airfoil. I tried using the code Conor provided, but I don't have a FluidZone or VelocityFunction that's needed for the script Conor posted to run. Help?
Hi Wei,
The fluid zone should only have a trigger collider attached to it:
The Unity collision system gets a little bit complicated when using triggers. To make sure it all works, the AeroObject must have a RigidBody component and a regular Collider (with IsTrigger set to false). The FluidZone must have a trigger Collider attached (IsTrigger set to true) and doesn't need a RigidBody component.
If the AeroObject is still colliding with your FluidZone, check that there are no Colliders in the children of the FluidZone, or other Colliders in the scene which could be causing the collision to happen.
Best,
Conor
Hi Conor,
Thank you very much for your response. Can the current functions of this package simulate the airflow effect of wind interacting with objects? Thank you!
Hi Wei Lin,
Thank you for your interest! We are currently working on a big update for the flow visualisation tools which will include more demos, tutorials and features. The update should be out in the next couple of months and will be part of the core AO package so no need to purchase any extras!
Best,
Conor