How do I make wind in the BGE?

In real life, objects that spin (like fans) create wind. I would like to make wind using Python, and apply it to an object for BGE usage, and when it blows, it will move the object away from the source, and if it sucks in air, the object moves toward the source and collides with it, and softbodies flap in the wind. You can see this effect on a fan and the surroundings when you reverse the fans direction/set wind intensity.

Mario 64 DS also does wind as well, how to do this, and what kind of script would be needed? I don’t want to make it by hand, as that would be days in some cases.


simply, add an cube at the wind spots, let the cube apply a force to any objects it hits, in the direction you want.
if with a switch simply add/remove the cube to turn in on/off

ok, do you want to affect all objects or just the player? or just objects with a certain property?

do you know python?

do you want local winds on each fan? or a global wind?

the script you need will vary depending on what you want, and in some cases there will be no need for python.

as for soft bodies, free soft bodies could be affected by wind, but bge does not support rigging of soft bodies (yet). you could use a simple ragdoll of rigid bodies, an armature and a skinned mesh, or just animate the movement.

here’s a quick script that applyies wind to all objects in a line:

import bge
cont = bge.logic.getCurrentController()
obj = cont.owner
scene = bge.logic.getCurrentScene()
objList = scene.objects

#objects with the property "wind" are affected
#the area that will be affected by wind. x1, y1, z1, x2, y2, z2. for diagonal shapes, more math needs to be involved.
area = [0.0, 10.0, 4.0, 4.0, 20.0, 0.0]
#center of the fan
center = [2.0, 10.0, 2.0]
#direction of the wind, also force
direction = [0.0, 10.0, 0.0]
#the property "fan_on" controls if the fan is on or off
if obj["fan_on"] == True:
     windy = [abc for abc in objList if "wind" in abc]
     if windy:
          for aec in windy:
               pos = aec.worldPosition
               if pos[0] > area[0] and pos[0] < area[3] and pos[1] > area[1] and pos[1] < area[4] and pos[2] > area[5] and pos[2] < area[2]:
                    aec.applyImpulse(center, direction, False)

you could also take these values from properties, and even activate the flag objects to play animations.
edit: oops. i forgot something in the script. fixed it.