UDN
Search public documentation:

InteractiveFoliageActor
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Static Meshes > InteractiveFoliageActor

InteractiveFoliageActor


Document Changelog: Created by Daniel Wright.

Overview


InteractiveFoliageActor is a new actor type as of QA_APPROVED_BUILD_DEC_2009. It is effectively a static mesh that receives forces from being pushed or shot and applies these to a spring system, which feeds the results into the FoliageNormalizedRotationAxisAndAngle node. This node can be hooked into WorldPositionOffset to animate the mesh with minimal performance impact.

Simple Setup


Simple Material Setup


All you need to get up and running is a FoliageNormalizedRotationAxisAndAngle affecting WorldPositionOffset, as seen below. Use the RotationAboutAxis node to rotate the object about this axis.

SimpleSetup.jpg

The subtract from Object World Position is to move the point that gets rotated down in world space. With this setup you can now push a bush out of the way, and it will spring back into place once you stop applying forces to it.

NotPushingCropped.jpg PushingCropped.jpg

Of course screenshots don't relay animation very well, so these videos show the result better.
WalkingThroughFields.mp4
Explosions.mp4

Advanced Material Setup


You can modify the Angle that gets fed into RotateAboutAxis to make the rotation affect parts of the mesh differently. For example you could store a weight in vertex color that controls stiffness, and use this to attenuate the angle. There's also a FoliageImpulseDirection node which provides the raw spring offset as a vector from the spring center to the simulated spring position. This can be useful if you don't want to do the animation with a rotation.

As an example here is a material which uses an offset from vertex color to change the rotation axis for different parts of the mesh.

AdvancedSetup.jpg

The Custom node in the material above is:

AdvancedSetup2.jpg

Here's a video of the material in action. Note how different parts of the mesh rotate in different directions when you touch it. This is useful for foliage types where you just want them to move around ambiguously when you touch them and not in a specific direction.

AdvancedAnimation.mp4

Be sure to use this in conjunction with some ambient wind animation for best results. The WindDirectionAndSpeed node is useful for coordinating wind animation between objects.

Spring Physics Settings


Each InteractiveFoliageActor has settings which let you control how the spring behaves. For example, if the spring is not moving enough when your character touches it, increase FoliageTouchImpulseScale.

SpringSettings.jpg

  • FoliageDamageImpulseScale - Scales forces applied from damage events.
  • FoliageDamping - Determines the amount of energy lost by the spring as it oscillates. This force is similar to air friction.
  • FoliageStiffness - Determines how strong the force that pushes toward the spring's center will be.
  • FoliageStiffnessQuadratic - Same as FoliageStiffness, but the strength of this force increases with the square of the distance to the spring's center. This force is used to prevent the spring from extending past a certain point due to touch and damage forces.
  • FoliageTouchImpulseScale - Scales forces applied from touch events.
  • MaxDamageImpulse - Clamps the magnitude of each damage force applied.
  • MaxForce - Clamps the magnitude of combined forces applied each update.
  • MaxTouchImpulse - Clamps the magnitude of each touch force applied.

There's no way to preview the spring's behavior in the editor so the best way to iterate is to create a small test level, and go into PIE to test interactions with the InteractiveFoliageActor.

Limitations


  • Currently InteractiveFoliageActor's block projectile weapons, since those do not yet respect PassThroughDamage.
  • Since WorldPositionOffset is used for animation, all the limitations of that apply. InteractiveFoliageActor's provide a visual-only effect.

Performance Implications


InteractiveFoliageActor's have very little performance overhead. They are effectively static meshes with precomputed lighting, and a static mesh is the fastest type of mesh to render. The only significant difference is that InteractiveFoliageActor's have a collision cylinder which is in the collision octree to receive Touch and TakeDamage events. InteractiveFoliageActor's are designed to be used everywhere that you would have placed a static mesh for foliage before.

Troubleshooting


Use 'show collision' in game or PIE to view the InteractiveFoliageActor's collision cylinder that is used for calculating the forces that are applied to the actor.

You can simplify the material to plugging in FoliageImpulseDirection into Emissive to debug whether the direction is changing when you touch it.

If your actors are not being affected by explosions, make sure their actor Location is above the ground. Explosions do line checks to each actor's Location before applying damage. You can see where the actor's Location is by where the movement widgets are drawn when selecting it in the editor. You can move the Location higher on the mesh by applying a PrePivot to the actor (under the Display category) and then translate the mesh back to compensate.