#1
|
|||
|
|||
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 ) |
#2
|
|||
|
|||
A hotspot is triggered when the viewpoint enters or leaves it. Here you have a hotspot that will be triggered when you enter it
Code:
ball1.starthotspot(BALL, viz.CIRCLE_HOTSPOT_IN, 0,0,20) It seems like a hotspot is not what you want here. Get the position of the first ball within a timer function and when it's at the position you want move the second ball towards it. |
#3
|
|||
|
|||
Thanks for your help, but what I want is something like proximity, instead of view entering a hotspot I want my object to enter that section and another action take place. Is there anything like proximity in vizard?
|
#4
|
|||
|
|||
Help With Physics
please help me with the above problem
|
|
|
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 |