1
$\begingroup$

I made a bowling-like game with bge. When the ball hits the pins they fall like they should do, because they are modeled as rigid body. But when I put them back in their position they start moving. I tried pulling up the damping to 1, setting cylindrical bounds and using these lines when I change position:

    cont = bge.logic.getCurrentController()
    target=cont.owner
    target.setLinearVelocity([0, 0, 0], True)
    target.setAngularVelocity([0, 0, 0], True)

but it isn't effective. Any suggestion?

Screenshot of the GameLogic

$\endgroup$
1
$\begingroup$

You can't cancel velocities with a null vector (0, 0, 0). A null vector is treated as "no change".

You need to apply a very small velocity such as (0, 0, 0.00002).

This belongs to the Python code as well as the motion actuator.

| improve this answer | |
$\endgroup$
0
$\begingroup$

I would not use Python to place the pins.

I suggest following:

  • Place the pin at the location they should be (each single one of them)
  • make a one frame action with RotLoc keyframe (i)
  • on reset play this action for exactly one frame.
| improve this answer | |
$\endgroup$
0
$\begingroup$

Found exactly the same thing while building fly navigation for the game engine. Here, paired keys WS, AD & RF instantly cancel each other before accumulating linear velocity in an opposite direction. My plan for this was to inject zero with a dedicated Motion actuator (using Set rather than Add of course) but, as Monster says, zero won't work, while a very small value does (the smallest I found worked was 0.0001, slightly larger than Monster suggests).

I have to say, this seems a bit wrong to me because the mouseover "Set" should mean set in my book, but there you have it.

It's also hugely displeasing to think that the object you were trying to stop has just been drastically slowed (with all that entails for CPU efficiency!). Never fear: a low velocity processing threshold can be set in the Object's Properties (Shift F7) » World » Physics » Physics Deactivation » Linear Threshold

May your velocities be tamed! :-) Peace/love

| improve this answer | |
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.