====== Interactions ====== Interactions are sway animations generated by interactors. \\ There are included two types of interactors: * **Wind Interactor** - for local wind zone. * **Primitive Interactor** - for collission with objects on scene. ---- ===== Interactor Projector ===== First of all, you need a projector on your scene that will collect nearby interactors and process them. \\ Projector is defined by volume, that defines frustum for internal camera used to scan, render and process interaction. * Create empty game object at the middle of your scene. * Add ''Interaction Projector'' component. {{:foliage:interaction_projector.png?direct&400|}} * **Texture Size** - quality of projector texture. * **MSAA** - texture multisampling. Increasing will also improve quality significantly, but at lower cost than texture size. * **Type** - type of projector: * **Local** - projector stays where it is, you simply define width and height of it. * **Infinite** - projector of square shape attached to camera (you can override this behaviour with Attach To option), you will use it mostly for larger areas that you cannot cover with local one * **Attach To** - in infinite mode by default it's attached to main camera and follows it's transform. You can change it to e.g. your character if you use 3rd person view. * **Lower & Upper Clip** - define frustum size for internal camera that will be used to render interactors. It's displayed as white wireframe on scene gizmo. Configure it so frustum can cover your entire area. Ideally, with extra margin. * **Scan Interval** - time in seconds between scanning for new interactors inside projector. You can always disable it by putting high value and do it manually throguh script by calling ''ScanInteractors()'' function. {{:foliage:interaction_projector_gizmo.png?direct&400|}} ---- ===== Interactors ===== **NOTE:** Whenever you create new interactor, it will force its game object to be on separate, dedicated for this feature layer. \\ Due to this, it is recommended to always have interactors as separate game objects in your hierarchy (e.g. child objects). \\ Read more: [[./dragon-foliage-config]] ==== Primitive Interactor ==== This is simple, mesh-based interactor that acts like a collider for grass to animate it down. \\\ There are two ways to create them: * **Method #1:** * Select any 3D object. * Click three dots on **MeshRenderer** component to open its' context menu. * Use **Create Foliage Interactor Mesh** option. * **Method #2:** * Create empty game object. * Add ''Primitive Interactor'' component. * Configure it according to instructions in inspector - use generic box, sphere or custom mesh. * In case of custom mesh it's recommended to use separate, simple low-poly mesh. By default primitive interactor will animate grass down towards current direction it moves. \\ You can offset it or force to use direction pointed by forward vector (blue one on gizmo in local mode). {{:foliage:interactor_primitive.png?direct&400|}} \\ {{:foliage:interactor_primitive_gizmo.png?direct&400|}} ==== Wind Interactor ==== Makes wind blow effect that can be generated by e.g. fan or rotor. \\ To create it: * Create empty game object. * Add ''Wind Interactor'' component. Wind Interactor has a bit more advanced shape that is visualised as gizmo when you have selected it in hierarchy. \\ Also, Wind Interactor is always aligned to XZ plane and only rotation along Y axis makes difference if you would like to move it. Shape configuration: * **Radius** - size of area. * **Inner Radius** - radius multiplier to define inner radius that will be used to blend from maximum to zero wind power. * **Cone** - 360 is full circle, reduce to make a cone that will point forward vector. * **Offset Height** - main Y position offset for entire area, usefull if you attach this to some moving object. * **Thickness** - shape thickness below offset height. Surface inside this area will be influenced by this wind with maximum power. * **Blend Height** - height below thickness area. Surface inside this area will be influenced by this wind reduced power, depending on distance to thick area. Wind configuration: * **Direction** - set direction offset for sway animation. * **Vertical & Horizontal Noise** - cosine-based noises. {{:foliage:wind_interactor.png?direct&400|}} \\ {{:foliage:wind_interactor_gizmo.jpg?direct&400|}} ---- ===== Assign Projector to Surface ===== Final step to have projector actually working is assigning it to your [[./foliage-surface]] in Sway tab. {{:foliage:interactor_projector_assign.png?direct&400|}} You can set projector in two modes: * **Common** - simpler version that will be processed only once for entire surface. Drawback is that it will use same simulation parameters on every plant on surface. You have option to define average plant height and stiffness parameters that will be common for entire surface. * **Individual** - a little more advanced method that will process projector in sub-passes - one for each layer on surface (but only if sway interaction is also enabled on layer). In this mode it will use actual plant dimensions and its' stiffness parameters defined in [[./layer-definition]]. Stiffness parameters: * **Bend** - how fast plant will go down if has to. * **Recovery** - how fast plant will go up to its original position when there is no more interaction. * **Direction** - how fast plant will change its' sway direction when direction of interaction changes. Works only if plant is not at its full sway level. Just like surfaces, you can have multiple projectors on your scene but you can assign only one to surface. \\ You can, however, have just one projector and assign it to multiple surfaces at the same time.