FIVE by FIVE

import bge,math

from mathutils import Matrix,Vector
def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner
    z = own.scene.objects['Empty.001'].worldPosition.z
    z-=.65
    z*=z*20
    #print(z)
    for obj in own.scene.objects:
        if 'Phys' in obj:
            v2 = obj.getVectTo(own)
            distance =v2[0]
            angle = v2[1]
            
            mat_rot = Matrix.Rotation(math.radians(90), 3, 'Z')
            angle_rot = angle @ mat_rot
            obj.applyForce(angle_rot*(33*z),0)
            obj.applyForce((angle*((distance*distance*.75)+(z*5))),0)
            obj.worldLinearVelocity*=.125
            for ob2 in own.scene.objects:
                if obj!=ob2:
                    v2b = obj.getVectTo(ob2)
                    
                    ob2.applyForce(v2b[1] * (200/(v2b[0])),0)
            obj.applyForce((0,0,obj.worldLinearVelocity.length),0)
main()

2 Likes

man !! this is crazy !!!
do the game engine detect any sounds on the pc ? because i see that the music isnt running on blender its self.?
also the motion nd the order of the objects. is it random or is it just animated nd thy just shake with the beat of the music ?

I baked the sound to a fcurve then unbaked it to keys, then play that action in the GE and use the objects worldPosition.z as a driver to feed to the physics forces

file at upbge discord*

1 Like