Hover, follow terrain, avoid obstacles

Hi All,
Does anyone know how to solve this?
I am trying to figure out how to have a gameobject go forward and roughly maintain a certain height from the ground, but to go up and over buildings when it encounters one, and then continue on…I’ve tried raycasting and oncollision and different combinations of triggers and rigidbodies but I cant seem to figure it out:
2605402--182589--upload_2016-4-21_15-17-51.png

I made a hovertank a long time ago (I seriously doubt I have the code still) and I ended up using several rays to get it working properly. Since you are also trying to go over buildings etc. I can think of one thing I’d try.

Basically it would involve shooting rays sideways (and maybe up a little) to check the sides and if it detects anything close to it, go ahead and increase your height until none of the raycasts return a hit.

My tank used 5 rays but it didn’t go over large objects. You could probably shoot 8 from the sides, 4 at angles from the bottom and then one straight down.

I hope it makes sense, I understand it’s Friday afternoon and nothing I say really makes sense this time during the week.

1 Like

Hey thanks! I will add some more rays and try that

Absolutely, good luck. Let us know how it goes.