Follow Terrain [Update 1/28: Works with FollowPath!]

This script is very similar to my Drop to Ground script (99% of guts are the same), but the functionality is different enough that I felt it deserved it’s own notice.

You can use this script as an object link through the script buttons. You can link it as a FrameChange or Redraw script, but I’ve found it fast enough (and fun) to use as a Redraw script.

When linked, it snaps the object center of the linked object to the surface of the mesh object called “Ground”. If you’re not over the Ground object, you move freely. If, however, you’re over the Ground object, then your linked object is free to move along in x and y, but follows the contour of the terrain.

So - if you want something to move along an irregular surface, all you have to concern yourself with is x and y movement - this script moves your object up and down according to the mesh it’s sitting on. It works with live motion in the 3D window and with keyframes. I haven’t gotten it to work with FollowPath constraint yet (which would rule, btw). It should be able to work in conjuction with other scripts that generate x and y motion (walking scripts, etc.).

In the sample .blend, the both the red and yellow balls are linked to the script. The red ball is for free-form play. The yellow ball has been given a couple of keyframes - hit alt-A to see it climb the hill!

Here’s the script, in a .blend:

Different script for riding the terrain for an object that is constrained to follow a curve:
It should work for any translation of the curve, but I wouldn’t go rotating or scaling it. So, with this version of the script, you should be able to take a 2D path that you’ve drawn over your terrain, give your object a FollowPath constraint to the curve, link the object to the script, and watch it follow the contour of the ground object while it follows the curve.

I’m going to try to generalize the script so a single version works in both cases (pathed and non-pathed).

Thank you, Harkyman! Both of your scripts sound great! I can’t wait to get at home in order to test them! Thank you very much, these script could be so helpful!!! Most of my scenes includes landscapes, which is my favourite part of CG… In POV-Ray, for example, I really have great and good time with the vegetation object placement include file… I expect to have quite the same good time with your scripts, now! 8)

This script rocks! I think it could be really useful for like a car animation or something having all the wheels follow the terrain. Keep up the good work!

Is it possible to put a gui on a script that is run on a refresh basis? if it is you should think about doing that and maybe it could be included with the release or something


I’m actually doing a car animation right now… This script will speed up the animation phase a great deal. Thank you! Great timing!

Please make it work with path animation soon. 8)

Great script, I have a script request which might not be that hard to implement for you: Slide. This should work in edit mode so that you can slide vertices along a line of edges.

like this:


means vertex

— means edge)

              selected vertex




This is in Wings3D and it is very useful. Say you want to increast the size of a complicated edge loop, you just select all the points in a loop and slide all the vertices to one direction (hope you understand).

Hopefully scripts will be able to be incorperated into other menus like the Mesh menu etc in the future, that is where this will belong.


That’s a great idea for modelling. I’m a Wings user too and I miss that functionality in Blender. It’s way beyond my coding capabilities, though. You should see who is working on the loop-cut tools in the current cvs builds - apparently, you can slide your newly cut loop exactly as you suggested. If you get to them before 2.32 is release (really soon now, I think), they could maybe include the ability to do this with a loop selection.

You would be loved by minions man if you pulled that off. Another great script!

Uhhh, some possible uses if I may be so bold as to say-

A tear drop or drops.

A drop or drops of moisture dripping down the side of a cold one, Yeah!

A ski dude, dude.

Endless possiblities…

whoa, thats f*cking awesome (sorry for the cussing stuff, but its really like WOW)

EDIT>> how do you incorperate this in another blend?

I believe you can right-click within the script window, select Save As, then save it out to a text file. You can then open a script window in your other .blend, use Open New from the header menu, and open the saved text file.

I’m glad you all like it!

You didn’t read what I said, I know its in the Import and Export menus, but I think it would be great if you could include scripts in other menus like the Object or Mesh menus.

ive done that, and named my mesh ground, but they dont follow it? ahow do you link them or something

Oh. This is in the manual and online docs, but I’ll just tell you here so you don’t overstress your clicky-finger.

Select your object that you want to follow the ground. Click on the scripts button (in the buttons windows between logic [purple pac-man] and shading [red sphere]). Click the NEW button to the left of “Scene scriptlink”.

A selection box appears. Set it to “Redraw”. In the textbox beside it, type the name of the script (“FollowTerrain” in this case).

That should do it.

hey harkyman thanks for the awesome script, it looks really fun and handy!

im just facing one problem, i dont know a line of code so its probably just the wrong build im using, i get a python script error then the line it highlights containts something alogn the lines of ‘drop x drop y’ ive tried every blender i own and it seems to want to gove the same line error if not a different line, any idea’s?

realy hoing i can get this script going i have some great needs for it, thanks =D

This is written and tested with the official Blender 2.31a release for Windows, and a full install of Python 2.2.3.

Check you versions. If it’s still giving you grief, please post the exact error message, and I’ll try to see what’s going on.

Updated to work with FollowPath constraints. Link to new script is in the first post.

is it possible to have it shape the path itself???

not the object attached to the path.

anyway i havn’t tried it yet but i shall for my lego animation it will rock i think. i will then just needt to deal with the rotation on the uneven terrain


Not really. YOU decide the path the object will take in the xy plane. If you’re looking at a textured version of your terrain from above (numpad-7), you’ll just be making your curve-path wherever on the map you want your car to go. The script will take care of making your model stick to the ground as it follows the path.


and i just need to do the tilting by myself now???

like the script only does the vertical direction righ??

anyway i will get onto it soonand start using it, it sounds cool.