WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-10-2009, 02:47 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You could apply a small force opposite the direction the ball is moving. Here a function is called ten times, the first nine times getting the velocity of the ball and applying a small force opposite to it. On the tenth time the ball is stopped completely.
Code:
import viz
viz.go()
viz.phys.enable()

ground = viz.add('tut_ground.wrl')
ground.collidePlane()

ball = viz.add('ball.wrl', pos = [0,1,8])
ball.collideSphere()

ball.applyForce([2,0,10], .1)

num = 1
def slowBall():
	
	global num
	
	#slow down the ball
	if num <10:
		vx,vy,vz = ball.getVelocity()
		ball.applyForce([-vx,-vy,-vz], .01)
		num+=1
		
	#stop the ball	
	else: 	
		ball.setVelocity([0,0,0])
		ball.setAngularVelocity([0,0,0])

#call function 10 times
vizact.ontimer2(.3,9, slowBall)
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
How to stop vizact.move Jerry Vizard 3 06-04-2009 04:25 PM
moving and object by mouse but don't know how to stop the movement nlfrnassimi Vizard 8 04-26-2009 07:23 AM
how can I stop an action? nlfrnassimi Vizard 4 02-13-2009 12:59 AM
timer question Elittdogg Vizard 5 10-10-2007 02:49 PM
moving viewpoint vs. translating Head_pos bailenson Vizard 5 02-01-2005 01:51 PM


All times are GMT -7. The time now is 05:12 AM.


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