How to make a projectile stay on ground level
I am implementing a Mario Kart like game. I decided to start with some of the fun traps that the original Mario Karts have. One of them is a turtle that goes in a linear direction and when it hits an opponent, the opponent is destroyed. I managed to get all this behavior done. However, I am facing an issue. My spawned actor (the projectile turtle) does not stay on the ground level. It starts going bellow or above the terrain (depending on the angle of the terrain). I would like to know if there is a way to make my projectile to always stay on ground level, and if so how to I do it.
asked Dec 13 '18 at 11:13 AM in Blueprint Scripting
There are several ways to do that.
I think the easiest way ist to decide for a fixed height, like 50cm aboth the ground. Then you do a Linetrace straight to the ground (0,0,1) and you will receive the current distance to the ground and position and so and. You can then say you want your objects z-coordinate (setWorldPosition) to be 50 aboth the hit point (be careful with world and local coordiantes)
If you want it more complex, you need the normal from the hitPoint and ou can set the angle of your shell accordingly.
answered Dec 13 '18 at 11:31 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here