If you’re looking to enhance your game even further, you may want to add more physics actors to your project, rather than just one character. These could be vehicles or other interactive objects, much like the Ball and Cube in our Alien World Demonstration level.
The process to do this is very similar to the process of adding interactable physics to your character. However, there are a few other variables to take note of, which we will cover in this guide.
In this example, we will start by creating a blueprint.
Choose Actor as your template.
Then drop in the mesh that you wish to interact with your foliage.
We must then enable ‘Simulate Physics’ in the mesh’s details panel.
Next, drag and drop BP_FoliageInfluencer into the blueprint.
Confirm that the Foliage Influencer is properly attached to the mesh within the object’s component hierarchy, ensuring synchronized movement.
As with the character, activate the Physics Radius visibility and adjust the influencer’s radius and position, ensuring that it slightly exceeds the object’s dimensions. If your object is elongated, you may want to duplicate the Foliage Influencer to accommodate it’s size. Having multiple smaller Foliage influencers may be better for performance than having a single large one, and it may also reduce any potential foliage conversion errors. However, keep in mind that having too many foliage influencers will also impact performance. We may improve upon this method in a later update.
Now, there are some additional variables that may need altering.
Typically, the player will always activate the foliage interactivity, as it’s consistently rendered by the camera. However, physics objects include additional performance optimization settings.
The “Active When” setting allows you to control the activation conditions of the foliage influencer. You might want it active at all times even if it’s not visible in the viewport. Or for better optimization, you might only want it active when it’s being rendered by the camera. For even greater performance optimization, you might activate it only within a specific range from the camera. You have the flexibility to adjust these settings as you wish, and you can also adjust this specified range by altering the “Active Range” variable.
Next, adjust the mesh’s collision settings to align with those of the character’s.
Don’t forget to disable the Physics Radius Visible variable, otherwise it will be visible ingame.
As a last crucial step, you will need to add the tag “Physics” to the blueprint actor. This allows the foliage blueprints to avoid disabling if this actor is still inside of their Deactivation capsule.
Now, if you throw that badboy in your level, it should be slapping those plants like a japanese chef slaps his totally legal whale steak!
Well, congratulations! You’ve mastered the basics of getting the foliage system working in your game, with your own characters and other interactable objects.