WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-15-2009, 09:13 PM
nlfrnassimi nlfrnassimi is offline
Member
 
Join Date: Feb 2009
Posts: 37
physics

Hi again, I'm doing a project and I'll need a lot of help.

I want an object to move in y axis and define a hotspot for it, then have another object which moves in x axis and at a point (hotspot) they will meet and collide.

I've been able to make them collide but my hotspot starts when I use my mouse, I want when my first ball reaches the hotspot the second ball goes to that position and collide.

I've done some things but it doesn't seem professional.

Please help me

here is my code:

Code:
import viz

viz.go()

viz.clearcolor( viz.GRAY )

viz.phys.enable()
viz.phys.setGravity(0,0,0)

ground = viz.add('tut_ground.wrl')
ground.disable(viz.PHYSICS)


ball1 = viz.add( 'ball.wrl')
ball1StartPos = ball1.translate(0,0.2,9)
ball1.collideSphere()

ball2 = viz.add( 'ball.wrl' )
ball2StartPos = ball2.translate(4,0.2,9)
ball2.collideSphere()

BALL = 1

def onHotspot(id,x,y,z):
	if id == BALL:
		ball1.applyForce( dir = [ 0, 0, 1 ], duration=0.01, pos = ball2StartPos )
		ball2.applyForce( dir = [ -1, 0, 0 ], duration=0.1, pos = ball1StartPos )

#def animation ():
#	
#	ball1.applyForce( dir = [ 0, 0, 1 ], duration=0.01, pos = ball2StartPos )
#	ball2.applyForce( dir = [ -1, 0, 0 ], duration=0.1, pos = ball1StartPos )
#	
#animation()

viz.callback(viz.HOTSPOT_EVENT,onHotspot)
#Attach a hotspot to the duck.
ball1.starthotspot(BALL, viz.CIRCLE_HOTSPOT_IN, 0,0,20)


viz.MainView.translate( 0, 2, -10 )
Reply With Quote
 


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
RE:Slide Joints and physics optimization nige777 Vizard 4 06-22-2009 04:21 PM
physics engine exception ad_astra Vizard 3 03-25-2009 11:31 AM
Physics and Haptics jalvarez Vizard 3 07-16-2008 03:03 PM
collision with physics enabled joeymax Vizard 2 04-17-2008 02:49 PM
Physics engine question adimov Vizard 2 07-22-2004 12:33 PM


All times are GMT -7. The time now is 11:17 PM.


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