Hello, everyone!
I’m working on a building system where a preview actor follows the mouse cursor. The preview actor must:
- Stay on the surface of the ground or objects.
- Restrict vertical (Z-axis) movement while adjusting to uneven terrain (e.g., hills or slopes).
Current Implementation:
- I use Get Hit Result Under Cursor by Channel to get the hit location.
- I set the actor location using Set Actor Location, but the movement happens in all directions, including Z.
- On uneven surfaces, the actor either floats in the air or sinks into the ground.
What I Tried:
- Subtracting the Z value from the hit result to restrict movement to the ground plane, but this causes issues on sloped or uneven surfaces.
- Adding a Box Collision to check overlaps with objects, but it sometimes fails when hitting walls or complex surfaces.
Problem:
- The preview actor sometimes loses collision detection and snaps inside walls or other objects.
- I need a way to keep the actor “snapped” to the surface while moving only on the X and Y axes relative to the ground plane.
Question:
How can I restrict the Z-axis movement while ensuring the actor stays properly aligned with uneven surfaces?
Here’s my current implementation for moving the actor:
- Get Hit Result Under Cursor by Channel for the hit location.
- Set Actor Location using the hit result.
Any advice on improving this or alternative approaches would be greatly appreciated!