Download

Weaving / Moving Grass / Plants Around Player

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:https://www.youtube.com/watch?v=w9W6YV5Wnys
20.png

Pros:
Looks cool.
Easy to make.

Cons:
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.

1d5f00916a0b531c956e8e6a2a122251615c137aa.jpeg

First we need to create a few assets.

One Material Parameter Collection.
One Blueprint.
One Material.

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.

22.png

Next, right click in the same area and create an Actor Blueprint, I named mine ProximitySensor_BP

33.png
42b9b5ee622c5a7165bd3bab7da78d0f792012960.png

The last asset we need is a material, right click on the empty space and create a Material, I’ve named mine WeavingGrass_Mat.

5d63bf0263edc2289f1662694aef71065504d1ef3.png

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.

60a618114f482d3ddd70a95598f3bb390b0e17c75.png

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.

8a16a2a8a21fe8b2b503dd569798216b8ec02f112.png
96023c2ae4f463303a34b7dfe127719a2a7e55241.png

Next, double click on the ProximitySensor_BP and head on over to the Event Graph tab.

1010.png

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.

1111.png

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.

12f29d340e705482d3405796d13f15d4d4dae0bfa1.png

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.

1347c2e9ccd7cb8097505cc8fe6c632fc133b7afb0.png

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 https://www.youtube.com/watch?v=JyX6LvdYLag and Barry Lowndes’s realistic grass https://www.youtube.com/watch?v=Z-XDMoMNnF4

Makeshift grass for testing purposes! We want to grab a Cone and throw it into the level.

1414.png

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.

1515.png

Now before we duplicate these blades of grass, type in ‘collision’ under the details panel and change the collision preset to NoCollision.

1616.png

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.

17e34c8e6ff3471a5c17f2f330d1409b79fef60ed9.jpeg

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.

181a1780e6eb72310e797fcc824893eb4fe8f8a653.jpeg

And well, there you go. A test patch to see if everything works.

1919.jpg

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!

Happy Hunting,
-Metric