WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-10-2009, 02:39 AM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
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
Reply With Quote
  #2  
Old 03-10-2009, 01:07 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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()
or for just the ball
Code:
ball.disable(viz.PHYSICS)
Reply With Quote
  #3  
Old 03-10-2009, 07:25 PM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
Can you please tell me how should I use the timer to get the ball position?

Thanks alot
Reply With Quote
  #4  
Old 03-11-2009, 03:43 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
When the z coordinate of the ball is greater than 10 it will stop
Code:
def stopball():
	
	pos = ball.getPosition()
	if pos[2] > 10:
		ball.disable(viz.PHYSICS)
	
	
vizact.ontimer(0,stopball)
Reply With Quote
  #5  
Old 03-11-2009, 09:26 PM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
Thanks alot for your help
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop for... loop Johannes Vizard 20 04-01-2014 02:53 AM
How to stop vizact.move Jerry Vizard 3 06-04-2009 05:25 PM
moving and object by mouse but don't know how to stop the movement nlfrnassimi Vizard 8 04-26-2009 08:23 AM
how can I stop an action? nlfrnassimi Vizard 4 02-13-2009 01:59 AM
When a video stop ? djdesmangles Vizard 2 01-11-2007 05:15 PM


All times are GMT -7. The time now is 06:34 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC