Entity.FindSweepHits Doesn't Hit Landscape

Summary

No Hits on Landscape when using the Entity.FindSweepHits() to find what is below my Prefab Entity

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

Create a Prefab with a single Entity. Add a mesh_component, transform_component and the following verse component.

using { /Verse.org/Simulation }
using { /Verse.org/SceneGraph }
using { /Verse.org/SpatialMath }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/Diagnostics }

sweep_test_component := class<final_super>(component):

    DownwardSweepDistance:float = 10000.0 # 100m
    DebugDraw:debug_draw = debug_draw{}
    
    OnBeginSimulation<override>():void =
        # Call parent implementation first
        (super:)OnBeginSimulation()
        
        spawn:
            RunLogic()

    RunLogic()<suspends>:void =
        loop:
            CurrentDistanceFromGround()
            Sleep(0.2)

    CurrentDistanceFromGround():float = 

        StartTransform := Entity.GetGlobalTransform()
        Displacement := vector3{Up := -1.0} * DownwardSweepDistance
        Extent := vector3{Up := 10.0, Left := 60.0, Forward := 90.0}
        Offset:float = 15.0
        CollisionVolume := collision_box{Extents := Extent, Collidable := true, Queryable := true}
        OffsetStartTransform := transform{
            Translation := StartTransform.Translation + vector3{Up := -Offset},
            Rotation := StartTransform.Rotation,
            Scale := StartTransform.Scale
        }
        
        # Debug
        StartPoint := StartTransform.Translation
        EndPoint := StartPoint + Displacement
        DebugDraw.DrawBox(Center := OffsetStartTransform.Translation, Rotation := OffsetStartTransform.Rotation, ?Extent := Extent, ?Color := NamedColors.LightGray, ?Duration := 0.2)
        
        # If we find any Hits, how far away are they?
        var ClosestDistance:float = DownwardSweepDistance
        var FoundAny : logic = false
        for (Hit : Entity.FindSweepHits(Displacement, OffsetStartTransform, CollisionVolume)):
            if (Hit.TargetComponent.Entity <> Entity):
                DebugDraw.DrawSphere(Hit.ContactPosition, ?Radius := 10.0, ?Color := NamedColors.Yellow, ?Duration := 0.2)
                CalculatedDistance:float = StartTransform.Translation.Up - Hit.ContactPosition.Up
                if (CalculatedDistance > 0.0 and CalculatedDistance < ClosestDistance):
                    set ClosestDistance = CalculatedDistance
                    set FoundAny = true
            else:
                DebugDraw.DrawSphere(Hit.ContactPosition, ?Radius := 10.0, ?Color := NamedColors.Green, ?Duration := 0.2)
                
        if (FoundAny?):
            DebugDraw.DrawLine(StartPoint, EndPoint, ?Color := NamedColors.Blue, ?Duration := 0.2, ?Thickness := 10.0)
            return ClosestDistance
        else:
            DebugDraw.DrawLine(StartPoint, EndPoint, ?Color := NamedColors.Red, ?Duration := 0.2, ?Thickness := 10.0)
            Print(Message := "Ground NOT found!", ?Duration := 5.0, ?Color := NamedColors.Red)
            return -1.0

Add some basic Landscape to the map. Drag and drop a number of the Entity into the world and run.

The verse script will draw a blue line if it encounters a sweep hit below itself within 100m. It will draw a yellow sphere at the point of the hit. Otherwise, it will draw a red line. A white box is drawn to represent the collision volume. And a green sphere is used to represent the start point of the sweep.

Expected Result

The line should be blue when over landscape with a yellow sphere at the ground level.

Observed Result

The sweep passes through the landscape without recording a hit.

Platform(s)

Windows

Upload an image




Additional Notes

I’ve tried a number of variations on the verse i.e. with and without a collision volume, with and without an offset. The result always the same.

I’m also experiencing this issue with FindSweepHits not detecting Landscape hits. In my case, I’m trying to spawn props at locations where the detected hits are flat/horizontal, using the contact normals to determine valid surfaces.

This works correctly when I’m using a floor prop. However, if I remove the floor prop and try detecting a flat Landscape instead, no hits are detected, and therefore no props are spawned.

The default cubes are the props I’m spawning, and the only difference between the screenshots is whether a floor prop is at the cubes’ spawn location.


1 Like

I was also curious whether Static Meshes were detected by FindSweepHits, but it appears they are not. I tried matching the Static Mesh collision settings to the same as the floor prop (Generate Overlap Events = True and Collision Presets = FortBuildingMeshPhysics), but that did not make any difference.

In these screenshots, you can see the floor prop to the left of the Static Mesh, and the cubes are spawning on it. However, in the screenshot where the floor prop is removed, the cubes are not spawned at all.


1 Like

FORT-1055631 has been created and its status is ‘Unconfirmed’. This is now in a queue to be reproduced and confirmed.

1 Like