In this tutorial I’ll try to cover everything so anyone who may be completely new to UE4 can follow along. If I’ve missed anything please let me know. Feedback on formatting is also appreciated. This is actually a very simple thing to create, but I’ve made the post long and detailed in order to encompass all skill levels.
TL;DR: Those of you who are experienced can just make the 3 assets (Blueprint, Material, Material Parameter Collection) and copy the blueprints from pictures #9,11,12 and 13. But make sure you put the ProximitySensor_BP in each level or it won’t work even with the applied material.
What this is:
Basically it’s a foliage collision effect. Grass will move out of the way of the player as they move through it. You see this effect in games like Grand Theft Auto 5, Wind Waker, and numerous other titles.
Quick Demo:Weaving/Moving Grass Around Player Tutorial Demo for Unreal Engine 4 - YouTube
Easy to make.
Uses an Event Tick.
I don’t have a grass model for you to use (Sorry! But I will show you a trick to test it out.)
I’m starting with the basic Third Person Example with Starter Content included.
First we need to create a few assets.
One Material Parameter Collection.
Right click on the empty space and under the materials list you’ll find Material Parameter Collection. Create one of these. I named mine PlayerLocation.
Next, right click in the same area and create an Actor Blueprint, I named mine ProximitySensor_BP
The last asset we need is a material, right click on the empty space and create a Material, I’ve named mine WeavingGrass_Mat.
Save! Also, I accidently made all the assets in the ThirdPersonBP file, so feel free to organize them as you see fit by dragging the files to other folders. There’s a little button on the left in the Content Browser called ‘Show or Hide Source Panel’ which you can click to see all the other files.
Alright, so let’s start with Material Parameter Collection.
Double click on PlayerLocation.
Add one Vector Parameter by clicking the + button which says Add Element when you hover over it. I’ll be making the Parameter Name match the file name, so PlayerLocation.
Next, double click on the ProximitySensor_BP and head on over to the Event Graph tab.
In here we’re going to be adding a bunch of nodes to basically get where the player is in the game. You’ll be right clicking on the empty spaces in the blueprint and typing in the node names and clicking on the ones you want to create them. Connecting them is as simple as clicking and dragging/dropping the wires from the Enter and Return pins (The little colored circle things).
Note: The nodes between Get Velocity/Get Actor Location and the Parameter Values are generated automatically when you hook the return values up to the parameter values.
Make sure under the Set Vector Parameter Value nodes that you select the PlayerLocation and PlayerVelocity assets that we created, and select the Parameter Name from the dropdown menu under Collection.
The height offset location will be important for determining where a sphere will be drawn around the player. It’ll make more sense later, but you may need to change the Z + value up or down based on your player model.
Compile and save!
Alright, now for the more difficult part. The Material.
Double click on the WeavingGrass_Mat to open it up. One of the first things you’ll want to do is drag the PlayerLocation Material Parameter Collection in from the content browser. You’ll need to click on this node and set the Parameter Name to PlayerLocation.
Everything that is labeled as “Scalar Parameter” has values that you can change. The values I set are what I thought worked well for my purposes. Play with them and see what you like.
You can click the little arrow next to the Component Mask node to expand a preview of what it’s doing. The whole reason for that is so when wind is applied to your grass, the bottom doesn’t move but the top does, like normal plant matter. Don’t worry about getting a grass model just yet, I’ll show you how I tested this with the basic models.
Now for the second part of the material. This is where you use the PlayerLocation.
Note: Strength determines how much the material is affected, and Distance determines how far away it’ll begin working on the material.
From this point on you could say you’re finished and just drop the ProximitySensor_BP into the level and the WeavingGrass_Mat onto a grass model. Stay tuned if you don’t have a grass model!
The ProximitySensor_BP needs to be in every level for the material to work properly.
If you want to play with the Parameters of the material without compiling each time, you can right click on the WeavingGrass_Mat and create a Material Instance. Double clicking on the created Material Instance will give you options to change the Parameters.
You may not have a grass model to test this with, so I’ll show you what I did for testing purposes. However, I do not recommend something like this for any sort of final product. There are great grass tutorials out there to help you with this. Shoutout to Resurrection 21’s Stylized Grass Stylized Grass | Tutorial | Blender to Unreal Engine 4 - YouTube and Barry Lowndes’s realistic grass Making Realistic Grass in Unreal 4 - YouTube
Makeshift grass for testing purposes! We want to grab a Cone and throw it into the level.
Press R to scale and grab the X and Y scalar and shrink it down until it looks like a blade of grass. You may have to turn snapping off in the top right for scaling.
Now before we duplicate these blades of grass, type in ‘collision’ under the details panel and change the collision preset to NoCollision.
Now just hit W to switch to transform mode, then hold Alt and grab the X and Y transform and move it, it’ll create a copy of the mesh.
Now just do this a bunch of times until you get what roughly resembles a patch of grass, maybe change the size around and make sure it’s on the ground.
You can select all of them by holding down Ctrl and left clicking each of them. Once they’re all selected, press Ctrl+G to group them together. You can use the Alt+Drag trick to make larger patches, but this is just for testing. In the details panel drag and drop the WeavingGrass_Mat into the Materials slot.
And well, there you go. A test patch to see if everything works.
Hope you found this tutorial useful and if you have any questions feel free to ask or leave a comment on Youtube (which I’m more likely to see sooner).
This tutorial was created from a number of sources I found all over the place, I would like to list all the places that helped me figure this out, but unfortunately my computer recently died and I lost all my research files. So if you know of any great grass tutorials feel free to post them here for others to see!