How do I calculate ground collision for placing objects in game?

I want to place a objects on/in the ground in game. Can someone point me to some techniques/tutorials to do that? Specifically I want to place foundations into the ground and detect the collision points so I can build structures.

Thanks!

Depends on your placement method. If you want to click on a screen to do that, then you can do a line trace through the cursor. The hit result it fills out will have a bunch of data you need to detect where a collision occurred.



FHitResult Hit;
GetHitResultUnderCursorByChannel(UEngineTypes::ConvertToTraceType(ECC_Visibility), true, Hit);


That method belongs to APlayerController (because it is a user input function) so this needs to be done on your PlayerController subclass.

Many other ways of doing it, though, depending on how you want your users to decide what to place there. What would your game require? Clicking with a mouse? Placing in front of a character? Etc.?