Custom class for foliage

I’d like to add collision to some of my foliage meshes, such that I can handle touch/untouch events for them.

Does anyone know how this can be done?

On a side note, it seems the foliage collision settings only handle blocking:

https://content.screencast.com/users//folders/Jing/media/20f85c0c-914c-4943-9405-54a1730b5e2c/2018-04-19_1210.png

I’d like to only collide and not block. Is this even possible.

Thanks in advance for any tips. Cheers

pretty sure they only added the option for a custom foliage class later in UE4 (wasn’t even there in UE4 4.0).
foliage in UDK is pretty much a black box anyway, in terms of accessing/using instance stuff from code

Maybe go reverse and make the player pawn search for foliage actors around him?

@ciox How would you go about searching for foliage? Using something like


foreach VisibleActors()

doesn’t seem to ever return foliage actors.

as I said, foliage is a black box inaccessible from code in UDK

if you absolutely require this you might need to handle your vegetation differently.
for example there was some snippet some time ago that would spawn and de-spawn mesh actors around the player as you’d move. but of course it’s not as optimized as using foliage so the rendering distance would be much inferior

Yeah i think the only way i can think of doing this is either place static mesh volumes in areas of dense foliage, and use touch events on those, or simply use static meshes instead of foliage. Think i’ll postpone any work in this area for now. Thanks for the responses.

You can access to each cluster looking in the foliage actor InstancedStaticMeshComponents.Length, and then find each mesh location with MatrixGetOrigin(PerInstanceSMData[index].Transform), and compare with the player location to see if they are colliding.

But probably it will be too slow. I use it to hide/unhide clusters but only a few of them in every tick.

Are you looking at player collision or vehicle collision on foliage actors?

if your looking at player collision like not walking thru certain foliages. In your static meshes. in your games upk files open that particular model and uncheck Use Simple Box collision this will cause you to not be able to walk thru the model if placed in map by itself. also uncheck Use Simple Rigid body Collision. This as a stand alone static mesh will cause vehicle collision to work.

With those unchecked and added as a foliage actor model.
If you put them into the foliage actor with both those uncheck the Use Simple Rigid body Collision. Will now work as player collision to not be able to walk thru that model, but for vehicles it seems there is no collision with the foliage actor.

Hope this helps, hope I made sense above. This is what we found when testing for vehicle foliage actor collision,