Adding GameObject setLinearVelocity(), without this interacting with objects requires them to have logic bricks to apply force which doesn't work well when the character is in a seperate blend file to the levels. (its also messy to have a script & multiple motion actuators on each object you can pickup and throw).
This is also needed for removing any force that existed before suspending dynamics - In the case of franky hanging, resuming dynamics when he fell would apply the velocity he had when grabbing making dropping to the ground work unpredictably. Also note in pydocs that enable/disable rigidbody physics doesn't work with bullet yet.
This commit is contained in:
@@ -812,6 +812,7 @@ PyMethodDef KX_GameObject::Methods[] = {
|
||||
{"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_VARARGS},
|
||||
{"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_VARARGS},
|
||||
{"getLinearVelocity", (PyCFunction) KX_GameObject::sPyGetLinearVelocity, METH_VARARGS},
|
||||
{"setLinearVelocity", (PyCFunction) KX_GameObject::sPySetLinearVelocity, METH_VARARGS},
|
||||
{"getVelocity", (PyCFunction) KX_GameObject::sPyGetVelocity, METH_VARARGS},
|
||||
{"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_VARARGS},
|
||||
{"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_VARARGS},
|
||||
@@ -1091,7 +1092,22 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self,
|
||||
PyObject* args,
|
||||
PyObject* kwds)
|
||||
{
|
||||
int local = 0;
|
||||
PyObject* pyvect;
|
||||
|
||||
if (PyArg_ParseTuple(args,"O|i",&pyvect,&local)) {
|
||||
MT_Vector3 velocity;
|
||||
if (PyVecTo(pyvect, velocity)) {
|
||||
setLinearVelocity(velocity, (local!=0));
|
||||
Py_Return;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject* KX_GameObject::PySetVisible(PyObject* self,
|
||||
PyObject* args,
|
||||
|
||||
Reference in New Issue
Block a user