Currently i'm trying different ways to make procedural generation of the grass on the terrain in BGE. Terrain itself is just a mesh. I've been thinking about just randomly placing grass meshes around the player and about making a place with grass which repeats itself in 4 directions around player and disabling these repeats as the player getting away and creating new. With the first case problem is that I dont know how to get the height and the normal of certain points of my terrain mesh, and with second one I dont know how to get geometry of the terrain and deform the grass plane according to it. I'm a BGE and python beginner and would appreciate any help and links to other effective ways of creating grass on the levels.


firstly my dude, no beginner should be undertaking this, it is a large scale project. secondly,

the easiest way to get a meshes height in the BGE is by using a raycast actuator tied to an object and returning it. (which in your case isn't even neccessary).

grass doesn't repeat but whatever, you can use random.seed to sorta accomplish this.

setXYZ is how you alter objects in realtime, which ALSO isn't what you want, as any 3 dimensional grass in a game is animated, and you don't see 3 dimensional grass in 3d games, as it looks poor and slows fraps. (you can however use it to place grass at vertices)

third you don't need the normals, like at all.

here is a working example of grass seeding.

created specifically for your purpose using the BGE.

if you want it to flow in the wind, or be hyper realistic you'll have to animate it yourself.

  • $\begingroup$ I feel like I should expand this answer. My example works with vertices so if you have a large grid this probably won't work for you. It will work with high poly terrains on a flat scape. If you are working with a larger grid then you will have to change the looping Structure to match either between 3 or 4 verts then calc the distance between the three and place the blades inside that face, instead of on the vert. This however means it is not possible to plant grass on subdivides which are inequal. $\endgroup$
    – Frederick
    Jan 15 '20 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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