WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-29-2011, 02:33 AM
Moh200jo Moh200jo is offline
Member
 
Join Date: Feb 2009
Posts: 99
Just an Idea to do it

I have 10 objects and want to do something if a collision happens between any of them and Box1. Box 1 can collide with other objects, but I do not want to do anything with that.
I have done that by writing if statement for all of them, but this way is really hard to accommodate
I have to write this
Code:
 if Box in viz.phys.intersectNode(Obj1) :
.
.
if Box in viz.phys.intersectNode(Obj10):
Anybody has an idea?
Thanks,
Moh
Reply With Quote
  #2  
Old 03-29-2011, 02:50 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can register a callback function for collision events. If each of these 10 objects has collide notify enabled:
Code:
<node3D>.enable( viz.COLLIDE_NOTIFY )
then whenever a collision happens with one of those objects the function will get called. Then you can check to see if the second node passed with the event object is the box:
Code:
#Called when two objects collide in the physics simulator
def onCollide(e):
    #Did object collide with box?
    if e.obj2 == box1:
        #Do something
        
viz.callback( viz.COLLIDE_BEGIN_EVENT, onCollide )
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Do you have some idea about the bicycle and wheel sled Vizard 6 08-01-2003 10:03 PM


All times are GMT -7. The time now is 08:47 AM.


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