RESOLVED: Explanation of Collision Flags

Software: Away3D 4.x

Alex Bogartz, Sr. Member
Posted: 19 October 2011 08:02 PM   Total Posts: 216

I know this was discussed in another thread, but that one is marked “resolved” so I haven’t seen any responses there.  My basic question is this:

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.

I’ve been reading up on the bullet physics forums, and the way I understand it 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 and trigger the callback, 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.

Is this possible?  If so, any example code?

   

Yang Li, Administrator
Posted: 20 October 2011 01:46 AM   Total Posts: 80   [ # 1 ]

looks it’s a bullet issue and have been fixed, http://code.google.com/p/bullet/issues/detail?id=197

but awayphysics still use the previous version. I will try to update and recompile.

 

   

Alex Bogartz, Sr. Member
Posted: 20 October 2011 01:51 AM   Total Posts: 216   [ # 2 ]

Ok, so I guess the good news is that I’m not clinically insane!  grin

 

   

Yang Li, Administrator
Posted: 20 October 2011 04:13 PM   Total Posts: 80   [ # 3 ]

I have tried, looks collisionFlags doesn’t work with character. But I have an idea to achieve this. you can use collision groups disabled the collision between character and bodies, then attach a rigidbody to the character, and set its collisionFlags to CF_NO_CONTACT_RESPONSE, add the collision event to it. now the character can pass through the bodies and trigger the callback.

here is a test that modified the CharacterDemo

 

File Attachments
CharacterDemo.as  (File Size: 12KB - Downloads: 702)
   

Alex Bogartz, Sr. Member
Posted: 20 October 2011 04:16 PM   Total Posts: 216   [ # 4 ]

I think the forum software won’t serve up .as files.  Will it work if you zip that file up?

 

   

Alex Bogartz, Sr. Member
Posted: 20 October 2011 09:07 PM   Total Posts: 216   [ # 5 ]

Hmmm, no matter what I try, this just isn’t working.  Can you copy and paste your code here?

I’m doing something like this:

var characterShape:AWPBoxShape = new AWPBoxShape(Mesh(_animCharacterMesh).maxX 2Mesh(_animCharacterMesh).maxY 2Mesh(_animCharacterMesh).maxZ 2);
var 
characterBody:AWPRigidBody = new AWPRigidBody(characterShapecontainer1);
characterBody.collisionFlags AWPCollisionFlags.CF_NO_CONTACT_RESPONSE;    
characterBody.addEventListener(AWPCollisionEvent.COLLISION_ADDEDcharacterCollisionAdded); 
physicsWorld.addRigidBody(characterBody)
var 
shape:AWPCapsuleShape = new AWPCapsuleShape(50100);
var 
ghostObject:AWPGhostObject = new AWPGhostObject(shapecontainer);    
ghostObject.collisionFlags AWPCollisionFlags.CF_NO_CONTACT_RESPONSE;
character = new AWPKinematicCharacterController(ghostObjectshape.1);
character.jumpSpeed 15;
character.warp(new Vector3D(013001000));
physicsWorld.addCharacter(character); 

No matter what I set the other objects to, the character still stops when he runs into any of these.  None of them are able to be walked through.

And

 

   

Yang Li, Administrator
Posted: 21 October 2011 01:37 AM   Total Posts: 80   [ # 6 ]

sorry, here is the code:

 

File Attachments
CharacterDemo.as.zip  (File Size: 4KB - Downloads: 365)
   

Alex Bogartz, Sr. Member
Posted: 21 October 2011 05:24 PM   Total Posts: 216   [ # 7 ]

Ok, works!  Thanks a lot!  So is this something we can fix with the character controller?  Perhaps by cloning the ghost object in the class and exposing that as a property for adding the collision response?  I’m not sure, just thinking out loud.

character.collider.addEventListener(AWPCollisionEvent.COLLISION_ADDEDcharacterCollisionAdded

Then you can just mark items for “pass through” as:

sensorBody.collisionFlags AWPCollisionFlags.CF_CHARACTER_OBJECT

Something like that.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X