I’m trying to implement functionality for placing buildings onto terrain (similar to how you would in a non-grid locked strategy game).
I’m using GetHitResultUnderCursor and/or GetHitResultUnderCursorByChannel to place the building at cursor location. Problem is, i want GetHitResultUnderCursor to only check for collision against actors with ECollisionChannel::ECC_WorldStatic components.
Right now my code looks like this:
if (GetWorld()->GetFirstPlayerController()->GetHitResultUnderCursor(ECollisionChannel::ECC_WorldStatic, false, hres))
The problem is, the preview actor is also a building actor that has collision set to a custom type and QueryOnly. GetHitResultUnderCursor sill returns collision with this preview actor Whats causing it to repeatedly fly towards the camera as it is constantly moved to its own collision point.
Reason i think it’s colliding against the preview actor is that if i set the mesh collision to NoCollision instead of QueryOnly, the preview actor stays at the terrain.
short recap:
preview actor
SetCollisionObjectType(ECollisionChannel::ECC_EngineTraceChannel2);
SetCollisionEnabled(ECollisionEnabled::QueryOnly);
GetHitResultUnderCursor(ECollisionChannel::ECC_WorldStatic
still returns hit against the preview actor.