# Spline Meshes don't bend smoothly.

**URL:** <https://forums.unrealengine.com/t/spline-meshes-dont-bend-smoothly/1343086>\
**Category:** C++\
**Tags:** spline-mesh-componen, unreal-engine, Spline, CPP, question\
**Created:** [October 24, 2023, 4:18pm UTC](https://forums.unrealengine.com/t/spline-meshes-dont-bend-smoothly/1343086 "2023-10-24T16:18:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meranolean](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meranolean](https://forums.unrealengine.com/u/Meranolean)\
**Post date:** [October 24, 2023, 4:18pm UTC](https://forums.unrealengine.com/t/spline-meshes-dont-bend-smoothly/1343086/1 "2023-10-24T16:18:01Z")

</div>

Hey! I tried to make a something like road. And I want to controll the number my texture will be repeated on this road. It would be perfect if every cell (I call a part of the road with 1 texture repeating “cell”) will be a separate mesh ot manipulate his location or texture color. Picture 1 shows how I did it in Unity. Also I want to set one texture for face part of my meshes and another textur for sides. I guess I need sockets for this but I don’t know how to specify it for mesh I created with UE Modeling.

I tried to use USplineMeshComponent and I was looking for a lot of ways to get what I want, but it still doesn’t work. I figured out that when I have few points in the spline my spline meshes don’t bend. In picture 2 it can be seen that in part 1 it’s ok, in part 2 it bend only 1-2 tilmes and in part 3 spline meshes are bended with bugs.

I’ll try to generate a few spline points with code, but it seems to be “not a perfect solution”. How really should I do what I want? Thank you!

Picture 1:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/f/abf468da4617d9844207c93c7b2a6414a287158f.png)

Picture 2: (My current road in wireframe mode)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/e/4/ce41e1c9fca1fe7b19be3baf8b00474c5ffd376f.png)

Pictrue 3: (Current road in lit mode)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/3/de3f416ef41cb3c89aed63e7aa8ef1dd4614718e.jpeg)

Pricture 4: (My Mesh) You might think there are too many vertices, but I already tried with fewer number of vertices, the result the same. But when there only 8 vertices (the simpliest cube) it works, but I need to combine a few meshes into one to make it single mesh and apply texture (material) on it.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/f/07fe6a94a8ae16052ac6f487b6a10469e02c2282.jpeg)

My code of spline mesh generation:

```auto
for (int i = 0; i < MeshNumber; ++i) {
	if (IsSkipping and i % 2 == 1) {
	    continue;
	}
	const float Time = float(i) / MeshNumber;
	const float NextTime = float(i + 1) / MeshNumber;
	auto NewMesh = NewObject<USplineMeshComponent>(this);
	NewMesh->SetMobility(EComponentMobility::Movable);
	NewMesh->SetStaticMesh(MapMesh);
	// NewMesh->SetWorldRotation(Spline->GetRotationAtTime(Time, ESplineCoordinateSpace::Local, true));
    NewMesh->SetSplineUpDir(Spline->GetDefaultUpVector(ESplineCoordinateSpace::Local));
	
 
	NewMesh->SetStartAndEnd(
		Spline->GetLocationAtTime(Time, ESplineCoordinateSpace::Local, true),
		Spline->GetTangentAtTime(Time, ESplineCoordinateSpace::Local, true),
		Spline->GetLocationAtTime(NextTime, ESplineCoordinateSpace::Local, true),
		Spline->GetTangentAtTime(NextTime, ESplineCoordinateSpace::Local, true)
	);
 
	NewMesh->SetStartScale(MeshScale);
	NewMesh->SetEndScale(MeshScale);

 
	NewMesh->AttachToComponent(Spline, FAttachmentTransformRules::KeepRelativeTransform);
	NewMesh->RegisterComponent();
}

```

---

<div class="post-metadata">

**Author:** ![HugoD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hugod/32/931219_2.png) [@HugoD](https://forums.unrealengine.com/u/HugoD)\
**Post date:** [May 3, 2024, 6:45pm UTC](https://forums.unrealengine.com/t/spline-meshes-dont-bend-smoothly/1343086/2 "2024-05-03T18:45:17Z")

</div>

Using the following blueprint script I get this result

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/e/9/5e95b91e1f6f1ad99cdb2baa8addd14021b9c6f2.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/7/3/b734d3b60159bc743f22b76f1d07f7cc1ea1d2bb.jpeg)
