Check contact/noncontact between two rigidbodies

Software: Away3D 4.x

entropic, Newbie
Posted: 16 July 2012 07:15 AM   Total Posts: 16

A simple question.
What i am wrong here?

I have a RigidBody with mass zero:  sceneBody
and a RigidBody which collide with it:  bodyC

and i want to permanent check the contact between this two objects

bodyC.addRay(new Vector3D(000), new Vector3D(0, -2500))

bodyC.addEventListener(AWPEvent.RAY_CASTcheckContact)
private function 
sphereRayCast(eventAWPEvent) : void { 
 
if (event.collisionObject == sceneBody{
  myText
.text "CONTACT"
 
}
 
if (event.collisionObject == null{// of course a NON PROGRAMMING script but ...only for exemplification
  
myText.text "NON CONTACT"
 

I just cannot find a way to have a CONSTANT CHECK of the contact and non contact

So….the stupid question..: How do i get the “null” contact…the NON CONTACT ??!!

I mean if i would have another body in scene…

private function sphereRayCast(eventAWPEvent) : void { 
 
if (event.collisionObject == sceneBody{
  myText
.text "CONTACT"
 
}
 
if (event.collisionObject == otherBody{
  myText
.text "OTHER BODY CONTACT"
 

...this work…

but again…how did i get the “non contact”

   

John Brookes, Moderator
Posted: 16 July 2012 12:50 PM   Total Posts: 732   [ # 1 ]

use the collision event if its not firing the rigidbody isnt in contact

eg

physicsWorld.collisionCallbackOn true;
//...
sphereRigidBody.addEventListener(AWPEvent.COLLISION_ADDEDsphereCollisionAdded);
//..
private function sphereCollisionAdded(e:AWPEvent):void 
{
 contact 
true
 trace
(contact)
}
//enterframe
contact false;
physicsWorld.step(dt6);
view.render();
trace("\t"+contact
   

entropic, Newbie
Posted: 17 July 2012 10:04 AM   Total Posts: 16   [ # 2 ]

He,...this is the standard “Physics Away Examples” solution but is not so “academic”.... at all.
As a nice impossible simple problem, i just ask this:

Let say i have a a text field , and i want to SIMPLE PUT IT IN ENTERFRAME WITH THE RESULTS :

//enterframe
    
if(contact == true){
     myText
.text "you are in contact with floor"
    
}
    
if(contact == false){
     myText
.text "you are in air"
    

I give a box of beer if it work….

   

Avatar
Ringo Blanken, Administrator
Posted: 17 July 2012 11:32 AM   Total Posts: 120   [ # 3 ]

Hey entropic,

I think John gave a nice answer did you try that ?
No need to use caps and thank you John.

 Signature 

Freelancer: http://www.ringo.nl/en/
http://www.jiglibflash.com
http://www.awayphysics.com
http://www.away3d.com

   

entropic, Newbie
Posted: 17 July 2012 05:02 PM   Total Posts: 16   [ # 4 ]

Nice indeed.
I did not take into account the exact “geometry” of the script.


I’m quite clear what happens

the exact call to work is:

//enterframe
   
contact false;
   
   
//rendering
   
scenaPhysics.step(timeStep); 
   
view.render();   
   
   
//check
   
if(contact == true){
    myText
.text "yes"
   
}
   
if(contact == false){
    myText
.text "no"
   

I owe a crate of beer…

   

John Brookes, Moderator
Posted: 17 July 2012 07:01 PM   Total Posts: 732   [ # 5 ]

http://away3d.com/donate/
smile

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X