RESOLVED: How to create Trigger Callback that doesn’t affect the physical world

Software: Away3D 4.x

Andrew R, Newbie
Posted: 19 September 2011 09:43 PM   Total Posts: 11

I want to be able to detect a collision between a specific moving object and an invisible shape in the rendered world and make a callback.

I don’t need all the extra functionality of characters.

I tried adding an event on a regular rigid body, but that also causes the objects to bounce apart.

   

Andrew R, Newbie
Posted: 19 September 2011 09:45 PM   Total Posts: 11   [ # 1 ]

I think I just found my answer.

I added
rigidbody.collisionFlags = AWPCollisionFlags.CF_NO_CONTACT_RESPONSE;
onto my rigid body.

Right?

   

Alex Bogartz, Sr. Member
Posted: 19 September 2011 09:57 PM   Total Posts: 216   [ # 2 ]

Thanks, Andrew, you solved my problem in the other thread as well.  For a constrained object to “push through” the character controller, set the flag on the object to:

constrainedBody.collisionFlags = AWPCollisionFlags.CF_NO_CONTACT_RESPONSE;

   

Yang Li, Administrator
Posted: 20 September 2011 02:54 AM   Total Posts: 80   [ # 3 ]

Yes, it’s work, but collisionFlags should be set like this:  rigidbody.collisionFlags |= AWPCollisionFlags.CF_NO_CONTACT_RESPONSE; because it maybe not have only one value.

   

HowlingBard, Newbie
Posted: 27 September 2011 03:00 PM   Total Posts: 20   [ # 4 ]

Hello again! I’ve got a very silly noob question: how do I do a sensor?
I understood that it’s the same thing that Andrew asked for, but something is going wrong here. I couldn’t even trigger a collision event.
I add the event “AWPCollisionEvent.COLLISION_ADDED” to my rigidbody, just when I create it in the init().
Am I doing wrong, adding a event this way?

   

Yang Li, Administrator
Posted: 27 September 2011 03:25 PM   Total Posts: 80   [ # 5 ]

you need set collisionCallbackOn first:

physicsWorld.collisionCallbackOn = true;

then:

yourRigidBody.addEventListener(AWPCollisionEvent.COLLISION_ADDED, collisionHandler);

private function collisionHandler(event : AWPCollisionEvent) : void {

}

   

HowlingBard, Newbie
Posted: 27 September 2011 04:40 PM   Total Posts: 20   [ # 6 ]

Well, I fell silly now. It worked and I just don’t believe, it was so easy!
Thanks once again Yang Li and sorry for the bother.

   

Alex Bogartz, Sr. Member
Posted: 17 October 2011 11:01 PM   Total Posts: 216   [ # 7 ]

Ok, is this working correctly?  If I set my rigidbody to:

AWPCollisionFlags.CF_NO_CONTACT_RESPONSE;

It should get the collision callback, but should NOT register a “bump”, correct?  Am I misunderstanding this?  In Unity, I seem to recall a flag you can set to set a rigid body as a trigger.  So it’s good for “you walked through this doorway” kind of interaction, where you can pass through the body, but it won’t actually apply forces.  But that doesn’t seem to be working here.  I can’t walk through a rigid body set to no contact no matter what I do.

Any help on this?

   

HowlingBard, Newbie
Posted: 18 October 2011 11:21 AM   Total Posts: 20   [ # 8 ]

Hi Mr. Bogartz, how are you?
Can you show us some code pieces? Just to know what you tried and how you’re doing.

   

Alex Bogartz, Sr. Member
Posted: 18 October 2011 04:31 PM   Total Posts: 216   [ # 9 ]

It’d be pretty hard to work up an example, but it’s pretty simple. Run the character demo in the physics examples.  Set any object to no contact response or create a cube with physics and set it to no contact response.  Shouldn’t those become triggers that you can walk through?  If not, how would you go about making a contact for something like walking through a doorway?

   

Alex Bogartz, Sr. Member
Posted: 19 October 2011 12:44 AM   Total Posts: 216   [ # 10 ]

I’ve been reading up on the bullet physics forums, and the way I understand is that you set up collision groups for each object.  And you can set some objects to ignore responses from another using collision flags.  But that’s not exactly what I’m trying to do.  I want the character controller to still register the collision, just not derive any force from it.  If I explicitly set the collision flags on the character to no contact, he still interacts with physical objects, but doesn’t trigger the callback.  I want the opposite of this.  Trigger the callback, but don’t interact physically.

   

HowlingBard, Newbie
Posted: 20 October 2011 12:45 PM   Total Posts: 20   [ # 11 ]

Hm. Mr. Bogartz I tried to set collision flags of the object , which would become my sensor object, to AWPCollisionFlags.CF_NO_CONTACT_RESPONSE and I added event AWPCollisionEvent.COLLISION_ADDED to it. It worked in my code, did you try this way?

   

HowlingBard, Newbie
Posted: 20 October 2011 12:50 PM   Total Posts: 20   [ # 12 ]

Oh, I forgot to say: are you using the line below in the constructor of your main?
physicsWorld.collisionCallbackOn = true;

   

Alex Bogartz, Sr. Member
Posted: 20 October 2011 02:58 PM   Total Posts: 216   [ # 13 ]

Well, I only added the collision event listener to the character, not the other object!  When I get to my dev machine I’ll try this.  It makes sense.  Thanks!

   

Aymeric, Newbie
Posted: 09 October 2012 08:33 AM   Total Posts: 9   [ # 14 ]

I’ve a problem with making sensors too : I don’t succeed to make a static sensor object. Collisions are always performed.

My sensor body is defined this way :
body = new AWPRigidBody(boxShape, mesh, 0);
body.collisionFlags |= AWPCollisionFlags.CF_NO_CONTACT_RESPONSE;

If I defined it as a dynamic body it goes through the floor :
body = new AWPRigidBody(boxShape, mesh, 1);

Any ideas?

Also how can I determine the Begin_Contact & the End_Contact?
_body.addEventListener(AWPEvent.COLLISION_ADDED, handleBeginContact);
This only reports contact all the time without differences.

Thanks for the help!

   

Aymeric, Newbie
Posted: 09 October 2012 01:03 PM   Total Posts: 9   [ # 15 ]

I’ve made several tests. In fact the problem is with AWPKinematicCharacterController. It works fine with a AWPRigidBody.

My character is defined this way :

override protected function defineBody():void {

 _ghostObject 
= new AWPGhostObject(_shape);
 
_character = new AWPKinematicCharacterController(_ghostObjectstepHeight);
}

override 
protected function createBody():void {

 _character
.warp(new Vector3D(_x_y_z));

 
_awayPhysics.world.addCharacter(_characte);

I’ve tried adding a collision flags, but without result :

_ghostObject.collisionFlags |= AWPCollisionFlags.CF_CHARACTER_OBJECT

What I’m missing?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X