Change foliage direction

I’ve added multiple blocking collision cylinders with a different translation to horse pawn actor and it appeared that foliage becomes glitchy while colliding with it. Instead of bending foliage away, it gets attracted to the front cylinder. Any ideas how to fix it?

058417de437e60f5bb3547afa451f98b5858b402.jpeg

Here’s the code of these additional cylinders, they are all same


Begin Object Class=CylinderComponent Name=CylinderF2
	AlwaysCheckCollision = True
	BlockNonZeroExtent = true
	BlockZeroExtent = true
	BlockActors=true
	CollideActors=true
	CanBlockCamera = False
	bBlockFootPlacement = False
	BlockRigidBody = True
	RBChannel = RBCC_GameplayPhysics
	RBCollideWithChannels = (GameplayPhysics = True)
	CollisionRadius = 70
	CollisionHeight = 117
	Translation = (X=150)
End Object
CylinderComponents(1)=CylinderF2
Components.Add(CylinderF2)

Cant help with that, but there are quite some talented coders here so you will get there.Meanwhile i wanted to ask if those are the gamecube assets?
Cooking some nice mode there? :cool:

Yeah, they’re from gamecube/wii.

I would suspect that the problem is with the shader. I assume that you’re using this setup? Does the same thing happen when Link walks through that grass?

Yes, it’s based on this example, but I have changed most of it. There were no problems with any other actors.
Perhaps, foliage just wasn’t meant to be used with actors having collision components with non-zero translation.

Is it possible to use a shape for collision that isn’t a cylinder? Or if you have to use a cylinder, can you make it lying down?

Cylinders can’t rotate. Basically, everything will collide as a world aligned box when it moves, unless it has rigid body physics. I’ll have to add multiple components of it and it will lead to this bug again. Oh, and rigid bodies have no effect on foliage :frowning:

I just thought of some crazy hacks that might work, or they might not.

Hack #1: Give your collision cylinders a negative radius. This might flip the direction that the grass gets pushed, but more likely it’ll just break a bunch of stuff or won’t compile.

Hack #2: Make the grass respond to wind instead of collision. Attach a wind source actor to your pawns. Instead of using sine-wave deflection for your wind shader, make it do what the interactive foliage would have done. If you have both wind and interactive foliage, then give your hacky pawn-based wind sources some really unusual wind speed (like negative, or a really high number), and put an if node to check to see if the wind has that exact unusual speed, and if so, then switch to collision mode. Does that make sense?

Edit: Of course, you could always just use a single collision cylinder. You might consider setting the horse’s origin to under the front feet. Or you could have the origin in the middle of all 4 feet, and just adjust the cylinder to find the right balance of pushing stuff away as far as possible to the front and back, without pushing too far to the side.

So, I decided to replace cylinder components with dummy actors based on horse.


class LZ_Dummy_Collision extends Actor;

var CylinderComponent CylinderComponent;
static function LZ_Dummy_Collision SpawnCollisionDummy(Legend_Pawn OwnerPawn, float Radius, float Height, Vector Translation)
{
	local LZ_Dummy_Collision Dummy;
	
	Dummy = OwnerPawn.Spawn(class'LZ_Dummy_Collision', OwnerPawn,, OwnerPawn.Location + (Translation >> OwnerPawn.Rotation),,, True);
	Dummy.SetBase(OwnerPawn);
	Dummy.CylinderComponent.SetCylinderSize(Radius, Height);
	return Dummy;
}

DefaultProperties
{
	Begin Object Class=CylinderComponent Name=CylinderComponent1
		BlockNonZeroExtent = true
		BlockZeroExtent = true
		BlockActors=false
		CollideActors=true
		CanBlockCamera = True
		bBlockFootPlacement = False
		BlockRigidBody = True
		RBChannel = RBCC_GameplayPhysics
		RBCollideWithChannels = (GameplayPhysics = True)
		CollisionRadius = 50
		CollisionHeight = 50
	End Object
	CollisionComponent=CylinderComponent1
	CylinderComponent=CylinderComponent1
	Components.Add(CylinderComponent1)
	
	bCollideActors = True
	bBlockActors = True
	bCollideWorld = False
	bMovable = True
	bStatic = False
	bHardAttach = True
}

They are spawned like that in horse’s PostBeginPlay:


CollisionDummies[0] = class'LZ_Dummy_Collision'.static.SpawnCollisionDummy(self, 60, 117, Vect(75,0,0));
CollisionDummies[1] = class'LZ_Dummy_Collision'.static.SpawnCollisionDummy(self, 70, 117, Vect(150,0,0));
CollisionDummies[2] = class'LZ_Dummy_Collision'.static.SpawnCollisionDummy(self, 60, 117, Vect(-75,0,0));

That way collision with foliage even works when the horse just turns around. But… these dummies don’t block player. Turning on BlockActors in cylinder component make them collide with the base and they begin move around it, even though bHardAttach is enabled. Is it possible to keep them on the same location relatively to the base while keeping BlockActors on?

Nevermind, fixed it by adding this to dummies. They were colliding with each other, not with the base.


bCollideAsEncroacher = True
bPushedByEncroachers = False