Download

How would one make a projectile that follows the ground level

Similar to how splines are used for roots to follow mesh and landscapes, I want one of my projectiles to follow the ground level, not go through it if there is an incline. How would I go about this?

This might be something to get you started. You could attempt to run a line trace from the projectile but directed downwards, and then modify it’s position based on the distance from the ground plane/landscape that it hits?

I do that but the projectile will still travel in a linear direction, not aligned with the ground. Even if you angle it based on the normal of the ground below you, that doesn’t keep the projectile from going straight through a hill, or straight off the ground if the ground declines.

Unless you mean do this every frame and adjust it every frame, then wouldn’t that be expensive? A line trace every frame on every projectile. Or I guess I could have it run every 0.1 seconds.

That would work and I can probably go with that if there is no better idea, but ideally I was hoping for a solution that I could run once, when spawning the projectile, and it would follow that path.
Maybe at spawn, run a line trace down to bring it to the floor, (adjust for projectile size), do a line trace forward, if it hits something check if its an incline or a wall, if it doesn’t hit anything then do some checks downward along that vector to see if the ground declines?

I really thought there would be a better way than to brute-force it

I’d likely make a Character Blueprint…it’ll have movement in it like a human…and either the mesh or a particle 250 units (or whatever works) above the ground…set it’s velocity in the character movement (small chance that doesn’t work and you’ll have to just use AI move to…but it should work since it’s not flying mode) and it’ll always stay on the ground since the root capsule doesn’t float unless you tell it to… I fake all my flying enemies this way, they look like they’re floating but they’re on the ground…