Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm looking for a solution for moving a variety of objects over the uneven surface of my planet. The idea is that I will have a number of objects that follow the planetary landscape moving about in random directions.

The planet surface is made up of 6 sphere projected planes, all have been displacement mapped to create a "bumpy" surface. A grid based movement system would be ideal as it lends itself to a lot of pathfinding solutions. I am also using Unity, so leveraging the Physics engine is an option, but past experience hasn't yielded very good results.

I'm having trouble understanding the best approach for realistic movement, would it be a matter of calculating gravity and then translating the object along its forward, right etc. Or on the other hand would It be more a case of pre-calculating the path from A to B and applying that movement.

enter image description here

I've looked all over for some ideas on this subject but have found nothing. A few suggestions would be greatly appreciated.

Thanks.

share|improve this question
3  
Can you be a little more specific? Where are you having trouble starting? (ex: How to represent the objects, the mathematics behind how to move the objects...) –  Alex Shepard Feb 16 '13 at 1:17
1  
You need to research four topics: vectors (determining vectors from coordinates, adding vectors), cross product (and surface normals), object space, and world space. The solution will be easy with that knowledge. Just remember that motion is applied to objects with respect to the surface normal whilst gravity is applied along the vector of two centers of gravity. –  SAHornickel Feb 16 '13 at 2:28
    
@SAHornickel I have limited knowledge in that area, enough to get by but it seems expanding this knowledge would be a huge benefit. Thanks for your suggestion. –  Caius Eugene Feb 16 '13 at 13:26

2 Answers 2

up vote 1 down vote accepted

Having used Unity before, I would try my best to leverage the physics engine as best as I could. Basically what I would do is represent the positions in polar coordinates + a rotation for facing direction. So essentially the polar coordinates would give you a unique position on a perfect sphere(which you could map to a grid keeping in mind that the grid wraps around and pinches off at certain places) and the extra rotation would specify the angle around the vector perpendicular to the sphere at that location. Unity and the physics engine will take care of the actual motion as long as you provide a constant gravitation "pull" from the centroid of the object towards the centroid of the planetoid. To create motion around the planetoid you simply need to provide a force perpendicular to the normal vector of the planet surface at that position rotated to the direction of travel around the sphere.

share|improve this answer
    
Thank you for this suggestion, this Unity perspective makes sense to me. I'll give this a quick go see what results I get. As for the polar coordinates, I think seeing as in theory I can 6 grids "faces", I think calculations should be done on that basis. Combining both your and @untitled 's solution may be the answer. –  Caius Eugene Feb 17 '13 at 12:07

You can treat the surface as a 2D heightmap of your planet.

This greatly simplifies the calculations needed; for gravity, simply apply a force downwards, and your main movement is on one plane. When you're done, you can simply convert the coordinates to the spherical coordinate system through some trig functions.

share|improve this answer
1  
+1 Those trig functions will still cost you, but in terms of simplicity, collision reliability and overall performance, I would recommend this approach over using Unity's inbuilt physics. –  Nick Wiggill Feb 17 '13 at 19:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.