Announcement

Collapse
No announcement yet.

Issue adding SplineMesh Components in runtime that causes Render and collision errors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Issue adding SplineMesh Components in runtime that causes Render and collision errors

    Hi!

    I'm trying to implement a sort of dungeon generator and I'm facing some issue adding the components in runtime.

    I have an actor class which has a spline component. The actor´s root and the spline are movables (componentMovility) and when I try to add a spline mesh component the Editor show this warning (but works properly):

    AttachTo: '/Game/Maps/UEDPIE_0_TestMap.TestMap:PersistentLevel.CorridorBP_C_0.CorridorRoot' is not static (in blueprint "CorridorBP"), cannot attach '/Game/Maps/UEDPIE_0_TestMap.TestMap:PersistentLevel.CorridorBP_C_0.SplineMeshComponent_0' which is static to it. Aborting.

    I suppose that it means that I can't attach a static component (spline mesh) to a movable component (actor root)... ok I change the movibility of the mesh component to movable: No warning but it does not work. I change the root and the spline to static: no warning but it does not work either.

    When I say it doesn't works that means the spline mesh components are no following the spline. They are located around the scene.


    Spline creation code:

    Code:
        USplineComponent* splineCmp = NewObject<USplineComponent>(this);
    
        splineCmp->AttachToComponent(RootCmp, FAttachmentTransformRules::KeepRelativeTransform);        
        splineCmp->SetWorldRotation(Direction.ToOrientationRotator());    
        splineCmp->RegisterComponent();
    Spline Mesh creation code:

    Code:
            USplineMeshComponent* SplineMeshCmp = NewObject<USplineMeshComponent>(this);        
            SplineMeshCmp->RegisterComponent();
            SplineMeshCmp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
            SplineMeshCmp->AttachToComponent(RootCmp, FAttachmentTransformRules::KeepRelativeTransform);
    
            int Index = FMath::RandRange(0, WallTileList.Num() - 1);
    
            SplineMeshCmp->SetStaticMesh(WallTileList[Index]);        
            SplineMeshCmp->SetForwardAxis(ESplineMeshAxis::X);
    
            FVector IniPos, IniTangent, EndPos, EndTangent;
    
            splineCmp->GetLocationAndTangentAtSplinePoint(i, IniPos, IniTangent, ESplineCoordinateSpace::World);
            splineCmp->GetLocationAndTangentAtSplinePoint(i + 1, EndPos, EndTangent, ESplineCoordinateSpace::World);
    
            SplineMeshCmp->SetStartAndEnd(IniPos, IniTangent, EndPos, EndTangent, true);
    In Addition, sometimes (without a specific pattern) the engine trigger an exception but If I continue from visual studio the project runs but some instanced meshes are not drawn and collisions does not work very well.

    Any idea to remove those warnings??

    Thanks!
    Last edited by Kanc; 04-06-2018, 10:55 AM.
Working...
X