![]() |
stop physic
Hi,
I have created a simple bouncing ball. I want it to stop when it reaches a particular point. But I don't know how. I'll appreciate any help. Here is my code for ball: import viz viz.go() viz.phys.enable() ground = viz.add('tut_ground.wrl') # Add ground ground.collidePlane() # Make collideable plane ball = viz.add('ball.wrl',pos=[0,.2,6]) # Add a ball ballPhys = ball.collideSphere(bounce = 2) # Enable physics on ball ball.applyForce([0,.3,.2],0.5) # Apply small force for half a second |
You could use a timer and get the position of the ball. Once its position has reached the point you specify you can either disable physics for the scene
Code:
viz.phys.disable() Code:
ball.disable(viz.PHYSICS) |
Can you please tell me how should I use the timer to get the ball position?
Thanks alot |
When the z coordinate of the ball is greater than 10 it will stop
Code:
def stopball(): |
Thanks alot for your help:)
|
All times are GMT -7. The time now is 11:19 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC