- Home /
how to make bullet ascend/descend relative to uneven ground level?
Hi, in my game the terrain is uneven. im trying to make a bullet to hover above the ground and descent/ascent relative to the ground elevation.
Answer by hugodeheld · Apr 09, 2018 at 10:49 AM
You could try raycasting downwards and then set it to hit.point + new Vector3(0,3,0)
its a shoot em up game. would it be too expensive do you think? it will be a lot of bullets flying around.
It depends on how many and the resolution you need and the speed of travel . If you have a thousand bullets doing this every fixedupdate frame then yeah,that would be expensive. But a hundred doing it every few frames would be fine. But if your bullets are traveling at 10 to 15 meters per frame then you will need it every frame. But only 1 meter then every 2 or 3 randomly will be fine.
Answer by davidcox70 · Apr 09, 2018 at 11:49 PM
If you are using a NavMesh for your ground, then this answer might help;
https://answers.unity.com/questions/1103597/get-height-of-point-in-navmesh.html
If your not, then as hugodeheld suggested, a raycast like below could be the answer;
https://forum.unity.com/threads/how-to-find-objects-height-above-terrain-mesh.2708/