hi I have been fighting with collision issues and movement on ground that glitches me through terrain. I wish to solve this by making my player character (a hand) float above the ground always at a set distance so it never collidges with the terrain… I know it has to do with linetraceing the ground but I really am not sure how to go about keeping my character at a set distance above the terrain. if someone could please help out with maybe a example are something I am not sure if I can even do this actualy because it is a player character not a pawn thanks in advance
if your using a character then the capsule shouldnt be falling through the terrain, i would first look to see if theres a collision issue with the terrain itself.
but since you asked, there are several ways to accomplish what your looking to do. if your looking to use a line trace then the basics would be to have the start point be the characters location and the end point would be the characters location minus the distance you want to the ground. now keep in mind the origin point of the character as it may not be the lowest point (i think the character default origin might be at the center of mass). you may need to add your character to the ignore list so you dont get a false hit. once you have the start and end point connected to your line trace your going to need to find the distance from your character to the hit location. to do this we again use some math, subtract the hit location from the players current location then get the length. now you can simply check if the length is less than a given amount and use a branch. now comes the part where you make a decision you can either just set the location or you can use physics to make the character get back to its required height. the physics method is shown [here][1].
personally i dont know that this is the best method for characters when theres things like the floating pawn movement but its what you asked for and should be a interesting thing to experiment with
thanks for the reply yes it is a strange iissue I have tried for days to change physics settings etc… I think the culprit is the way I have the player character setup but I want it this way. and seems the springarm is causeing random glitches through the terrain mostly at angled slopes…i think I will have to do some sort of front line trace as well to go above or over slopes and hills… are it may just run right into it the same way… this was the only option I see that may fix my problem… I will try this and let you know… I am new to the engine and game dev altogether. but trying to learn… thanks again I will try this when I get to my pc.
Yes… I agree with Thompson… the collision capsule itself should work just fine with terrain.
As for any Camera Component on a Spring Arm Component, it will for sure clip inside things which certainly looks odd. But this is a different issue!
The first step is… in the Spring Arm Component… turn on Do Collision Test. The camera will automatically move closer to your character when it collides with things. If this doesn’t suit your needs, then you can start adding some more fancy code
also note one the camera issue that it will only collide with objects set to block camera channel