I'm using the BGE and I need to change the position of a group of vertex of a soft-body while the game is running. I've tried with the code below but I don't see any change. If I print the new position of the vertex I can see in console that the value change but in the soft-body I don't see anything different. I've tried using obj.reinstancePhysicsMesh(obj,mesh) at the end of the code but that change the position of the entire mesh. How could I do?

import bge
import bpy
cont = bge.logic.getCurrentController( ) 
own = cont.owner
scn = bge.logic.getCurrentScene( )
obj = scn.objects["object1"]
mesh = obj.meshes[0]
for v in range(0,1000):
    vert = mesh.getVertex(0, v)
    vert.XYZ = [1.0, 1.0, 1.0]
  • 1
    $\begingroup$ I think it is not possible with a soft body, because Blender calculates every Frame a new position for every vertice with the position of the vert in the frame before. So Blender dont expect a position changement while running, Blender is using the mesh of the frame bevore. (Its just a guess, I'm not shure.)(It works fine with other Physics types) $\endgroup$ – Leon95 Jun 5 '14 at 9:45
  • $\begingroup$ Thank you. I see, if I change the object to rigid body it works. $\endgroup$ – Andrea Jun 5 '14 at 10:19
  • 1
    $\begingroup$ Note that the loop should look like: for v in range(0,mesh.getVertexArrayLength(0)): otherwise an exception occurs. $\endgroup$ – stacker Jun 8 '14 at 9:57
  • $\begingroup$ Yes, look at the code used in this video, the waves are by changing mesh vertices in real time PREVIEW 1:56 blender game engine :waves YouTube · vicent adnawm Jan 29, 2016 $\endgroup$ – vicent adnawm Jun 25 '19 at 2:40

Your Answer

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

Browse other questions tagged or ask your own question.