I’m trying to make grenade trajectory with spline component and spline mesh. Have looked through some tutorials. I know there’s a function called Add Spline Mesh Component
in Blueprint (I don’t know why many people use this while the description says don’t call it manually), but there’s no equivalent in C++. So I tried something like this:
After getting the spline points, I loop over the points and create new spline mesh.
USplineMeshComponent* NewMesh = NewObject<USplineMeshComponent>();
NewMesh->SetStaticMesh(BaseSplineMesh);
NewMesh->Mobility = EComponentMobility::Movable;
NewMesh->AttachToComponent(PredictionSpline, FAttachmentTransformRules::KeepRelativeTransform);
NewMesh->RegisterComponent();
SplineMeshes.Add(NewMesh);
// ...
// get / set location and tangent stuff.
where SplineMeshes
is a TArray<USplineMeshComponent*>
used to stored the spline meshes.
But I can’t see any spline mesh in game (the spline itself looks good). I even get an error at SplineMeshes.Add(NewMesh);
(no detailed info, VS just says A breakpoint instruction (__debugbreak() statement or a similar call) was executed in UnrealEditor-Win64-DebugGame.exe.
). But it will continue to run if I press Continue button.
So could someone please tell me what’s going on here? What’s the correct way to do this?