I keep the avatar in my app above the terrain by checking the x and z location every frame and then positioning it at the appropriate y point (i.e. the height of the terrain at point y) - I’ve seen methods of collision avoidance implemented before using picking, it seemed fairly complex. I want mine as simple as possible so I plan to do it like this:
- Add the objects to the terrain so the avatar would go over them regardless of their height
- At every frame, store the current x,y and z co ordinates
- Then calculate the hieght of what the new x, y and z coordinates will be
- If the the new y coordinate has too greater difference between that and the old one (relative to the differences betweeen the x and y as this will reflect the speed) then keep the avatar in the position of the old x, y and z.
The value that represents the difference between the old y and new y cordinates would in effect be how steep the avatar can climb.
Is this a documented mothod of collision avoidance?
How good is this, speed wise, compared to other methods - I favour speed over accuracy.
Thanks.