How do I make a Wave modifier be positioned so the ripple is where an object hits the mesh?

As how the title says, how can I create a piece of code that works like this:

  1. A pool of water (in this case, a plane) is below a cube that is dropped into the plane.

  2. When the cube strikes the object, the plane’s code tells a Wave modifier to play, and positions the ripple to be created on impact of the cube or something else. This needs to happen as many times as possible.

  3. Any objects dropped into the plane will float if they have the ‘water’ property (this is denser for lava, and mud, and must be an easy set-up)

  4. The water (or lava or mud) has buoyancy and this is adjusted via a ‘thickness’ property.

This works like Monsters swim demo water simulation but for UPBGE 0.3+. That was a good one, but incompatible with UPBGE 0.3, and force fields arent perfect at simulating buoyancy.

A work-in-progress script I whipped up. It adds a wave modifier if the colliding object is initially touching, and makes the wave follow the objects’ if they move.

import os, bpy, bge

os.system("cls")
print("Blender Game Engine Started")

COLLIDED = []
self = bge.logic.getCurrentController()

def check_collisions(obj):
    
    if obj not in COLLIDED:
        COLLIDED.append(obj)
        wave = bpy.data.objects[str(self.owner)].modifiers.new(name="WAVE", type="WAVE")
        wave.start_position_object = bpy.data.objects[str(obj)]
        
def main():
    
    self.owner.collisionCallbacks.append(check_collisions)

Again, it’s still very much in prototype phase. I will try to work on property checking next and also try implementing dynamic settings for the modifier per-property type. Should be easy enough to do by creating some custom class types.

1 Like

I actually adapted some of that code (did not need the waves), for a UV scroll script I made. The UV scroll script makes a new modifier called a UV warp modifier, in which the values are manipulated through game properties in the script. Thanks for actually helping me out with some UV scrolling dilemma I had.

But why does UPBGE’s sprite animation node not work properly with water normal map sprite sheet textures?

you have to ensure you are using non color - and ‘closest’ for the mipmapping

also use normal map node - there is upbge faster normal map node and also a fix for it recently*

1 Like