nikki
27-12-2006 08:15:56
In my game, there is a teleportation device. After teleporting, the Player continues to move in the direction he was moving before teleportation (ie. linear velocity is not 'zeroed'). To teleport I just used this code (assuming 'pos' is the target and 'mBody' is the Player's Body):-
mBody->setPosition(pos);
But it gives me an error saying 'invalid operation for locked space'.
My question is: How can I fix this? Is there any other better way to teleport?
Thanks!
Dirso
27-12-2006 17:58:32
Hi,
I'm a newbie, but did you try to disable physics for this and then enable it again?
nikki
28-12-2006 07:29:29
Hi,
I'm a newbie, but did you try to disable physics for this and then enable it again?
Disable physics? Like disabling the Geometry? Or how?
Dirso
28-12-2006 10:39:11
I would try this:
_stepper->pause(true);
mBody->setPosition(pos);
_stepper->pause(false);
I hope it helps!
Dirso
maybe isn't usefull what i'm going to say but i move a OgreOde_Prefab::Vehicle during simulation paused and running with no problems at all.....
are you doing something uncommon in the way you build & setup the object ( body +geometry + setting the mass + waking up or turned to sleep, etc) ?
nikki
28-12-2006 21:22:03
I think the problem is that it is attached to another body by a hinge joint. Look
here for an explanation. mBody is the Player's body (the 'wheel' part of a bicycle's front part).
Is there anyway to temporarily 'deactivate' a (hinge) joint?
i think OgreOde_Prefab::Vehicle is a similar case, a body and four spheres attached to the body by joints, you could try something like this:
//------------------------------------------------------------------------------------------------
void Vehicle::setPosition(const Vector3& position)
{
for (std::vector<Vehicle::Wheel*>::iterator i = _wheels.begin();i != _wheels.end();i++)
{
Vector3 diff = (*i)->getPosition() - _body->getPosition();
(*i)->setPosition(position + diff);
}
_body->setPosition(position);
}
i hope this helps !
EDIT: may be the difference with your code is that the above code also moves all attached objects adding local offsets.
nikki
30-12-2006 06:08:55
Luis, I tried that. It still gives the same error. It seems that it happens only when I move the 'wheel' body in the hinge joint and not the 'handlebar'. It may also be due to the fact that the 'wheel' body has a geometry and the 'handlebar' doesn't. Or that the 'handlebar' isn't affected by gravity, but the 'wheel' is.
The error message says it happens at collision_space.cpp, line 55.
hmmm seems you have to trace what is doing OgreOde in this particular case... sorry i couldn't help.
tuan kuranes
12-01-2007 15:54:03
it's an ODE problem, so you might try Ode mailing list.
That said, It doesn't seem correct to change position of a body connected to a joint, or you'll have to move the whole thing connected.
You can also delete/recreate the object needed to avoid this