Problems with Linear velocity

Hi I have a dynamic object (not rigid body) like a ping pong ball. I want to
use a script that reduces its linear velocity to zero in each of the x,y,z axis, making it stationary.

After this I want to then use another script to reset its velocity to say 0.0, 10.0, 0.0.

My current script to make the object stationary is:

cont = GameLogic.getCurrentController()
own = cont.getOwner()
sen = cont.getSensors()
act = cont.getActuators()

if sen[0].isPositive():
act[0].setLinearVelocity(0.0, 0.0, 0.0, 1)
GameLogic.addActiveActuator(act[0],1) # Motion actuator

Another script I tried is:

cont = GameLogic.getCurrentController()
own = cont.getOwner()
sen = cont.getSensors()
act = cont.getActuators()

if sen[0].isPositive():
GameLogic.addActiveActuator(act[0],0) # Motion actuator

If you have any ideas or a working example that you could share I would really appreciate it. Thx.

Any errors in the console? If not try suspendDynamics.

The whole speal with linV is that setting it to 0,0,0 and firing the actuator doesn’t do anything. I think you need to get the object’s velocity and set the linV brick to exactly negate that (I don’t have time now, maybe someone else can write a short script).

If not try suspendDynamics. [MagicMan] - suspendDynamics doesn’t stop the object, it seems to turn off the bounding sphere so that no collisions are detected with walls etc.

…get the object’s velocity and set the linV brick to exactly negate that … [Toomai]- I wrote the following script to do just that but it had no effect:

cont = GameLogic.getCurrentController()
own = cont.getOwner()
sen = cont.getSensors()
act = cont.getActuators()

if sen[0].isPositive():
vel = own.getLinearVelocity()
vel[0] = -vel[0]
vel[1] = -vel[1]
vel[2] = -vel[2]

act[0].setLinearVelocity(vel)
GameLogic.addActiveActuator(act[0],1)

I had trouble with something like this as well, never gotten around to making it work though.

“act[0].setLinearVelocity” takes 4 arguments (three for xyz coords and one for L (local transformation))

the “own.getLinearVelocity” returns a list with only the 3 xyz coords.

What console messages are you recieving?

PS:

Please use the [-code-] tags when your posting your scripts

What console messages are you recieving? - [Social]

No errors in the console. The codes work fine - just that nothing happens.

The only thing that comes close to fixing the problem seems to be to use the setForce option to reduce the x,y,z linear velocities. This option is too hit and mis though. My suspicions is that the orientation of the object has to be used in conjunction with the x,y,z velocities to make the object stationary - any other ideas…

The orientation shouldn’t have anything to do with it.

If only there was a way to directy change the velocity of an object without using logic bricks. Say a method like setVelocity([4,-3,7]). Then anything like this would be so easy.

Exactly.

To tell you the truth I was surprised that there was no such function, since they have setPositon() and such.

mabye this is what you want?
http://www.freewebs.com/scabootssca/Files/BrakeTest.blend

Scabootsca the name of this blend looks promising - too bad I can’t open it. I’m using Blender 2.36. When I try to open it I get the following error in the console:

In BPY_call_importloader(name= path...BrakeTest.blend)

Don’t suppose you could save it from 2.36?
Or post the relevant snippets of code?